Skip to content

Commit d327bb1

Browse files
committed
Update with edition idioms.
1 parent e39a0ac commit d327bb1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+323
-378
lines changed

examples/add.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,9 @@
1515
#![deny(warnings)]
1616
#![allow(trivial_casts)]
1717

18-
extern crate docopt;
19-
extern crate git2;
20-
#[macro_use]
21-
extern crate serde_derive;
22-
2318
use docopt::Docopt;
2419
use git2::Repository;
20+
use serde_derive::Deserialize;
2521
use std::path::Path;
2622

2723
#[derive(Deserialize)]
@@ -71,7 +67,7 @@ fn run(args: &Args) -> Result<(), git2::Error> {
7167
}
7268

7369
fn main() {
74-
const USAGE: &'static str = "
70+
const USAGE: &str = "
7571
usage: add [options] [--] [<spec>..]
7672
7773
Options:

examples/blame.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,9 @@
1212
* <http://creativecommons.org/publicdomain/zero/1.0/>.
1313
*/
1414

15-
extern crate docopt;
16-
extern crate git2;
17-
#[macro_use]
18-
extern crate serde_derive;
19-
2015
use docopt::Docopt;
2116
use git2::{BlameOptions, Repository};
17+
use serde_derive::Deserialize;
2218
use std::io::{BufRead, BufReader};
2319
use std::path::Path;
2420

@@ -91,7 +87,7 @@ fn run(args: &Args) -> Result<(), git2::Error> {
9187
}
9288

9389
fn main() {
94-
const USAGE: &'static str = "
90+
const USAGE: &str = "
9591
usage: blame [options] [<spec>] <path>
9692
9793
Options:

examples/cat-file.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,11 @@
1414

1515
#![deny(warnings)]
1616

17-
extern crate docopt;
18-
extern crate git2;
19-
#[macro_use]
20-
extern crate serde_derive;
21-
2217
use std::io::{self, Write};
2318

2419
use docopt::Docopt;
2520
use git2::{Blob, Commit, ObjectType, Repository, Signature, Tag, Tree};
21+
use serde_derive::Deserialize;
2622

2723
#[derive(Deserialize)]
2824
struct Args {
@@ -132,7 +128,7 @@ fn show_sig(header: &str, sig: Option<Signature>) {
132128
}
133129

134130
fn main() {
135-
const USAGE: &'static str = "
131+
const USAGE: &str = "
136132
usage: cat-file (-t | -s | -e | -p) [options] <object>
137133
138134
Options:

examples/clone.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,10 @@
1414

1515
#![deny(warnings)]
1616

17-
extern crate docopt;
18-
extern crate git2;
19-
#[macro_use]
20-
extern crate serde_derive;
21-
2217
use docopt::Docopt;
2318
use git2::build::{CheckoutBuilder, RepoBuilder};
2419
use git2::{FetchOptions, Progress, RemoteCallbacks};
20+
use serde_derive::Deserialize;
2521
use std::cell::RefCell;
2622
use std::io::{self, Write};
2723
use std::path::{Path, PathBuf};
@@ -52,7 +48,7 @@ fn print(state: &mut State) {
5248
let kbytes = stats.received_bytes() / 1024;
5349
if stats.received_objects() == stats.total_objects() {
5450
if !state.newline {
55-
println!("");
51+
println!();
5652
state.newline = true;
5753
}
5854
print!(
@@ -115,13 +111,13 @@ fn run(args: &Args) -> Result<(), git2::Error> {
115111
.fetch_options(fo)
116112
.with_checkout(co)
117113
.clone(&args.arg_url, Path::new(&args.arg_path))?;
118-
println!("");
114+
println!();
119115

120116
Ok(())
121117
}
122118

123119
fn main() {
124-
const USAGE: &'static str = "
120+
const USAGE: &str = "
125121
usage: add [options] <url> <path>
126122
127123
Options:

examples/diff.rs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,11 @@
1414

1515
#![deny(warnings)]
1616

17-
extern crate docopt;
18-
extern crate git2;
19-
#[macro_use]
20-
extern crate serde_derive;
21-
22-
use std::str;
23-
2417
use docopt::Docopt;
2518
use git2::{Diff, DiffOptions, Error, Object, ObjectType, Repository};
2619
use git2::{DiffFindOptions, DiffFormat};
20+
use serde_derive::Deserialize;
21+
use std::str;
2722

2823
#[derive(Deserialize)]
2924
#[allow(non_snake_case)]
@@ -64,11 +59,11 @@ struct Args {
6459
flag_git_dir: Option<String>,
6560
}
6661

67-
const RESET: &'static str = "\u{1b}[m";
68-
const BOLD: &'static str = "\u{1b}[1m";
69-
const RED: &'static str = "\u{1b}[31m";
70-
const GREEN: &'static str = "\u{1b}[32m";
71-
const CYAN: &'static str = "\u{1b}[36m";
62+
const RESET: &str = "\u{1b}[m";
63+
const BOLD: &str = "\u{1b}[1m";
64+
const RED: &str = "\u{1b}[31m";
65+
const GREEN: &str = "\u{1b}[32m";
66+
const CYAN: &str = "\u{1b}[36m";
7267

7368
#[derive(PartialEq, Eq, Copy, Clone)]
7469
enum Cache {
@@ -267,7 +262,7 @@ impl Args {
267262
}
268263

269264
fn main() {
270-
const USAGE: &'static str = "
265+
const USAGE: &str = "
271266
usage: diff [options] [<from-oid> [<to-oid>]]
272267
273268
Options:

examples/fetch.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,9 @@
1414

1515
#![deny(warnings)]
1616

17-
extern crate docopt;
18-
extern crate git2;
19-
#[macro_use]
20-
extern crate serde_derive;
21-
2217
use docopt::Docopt;
2318
use git2::{AutotagOption, FetchOptions, RemoteCallbacks, Repository};
19+
use serde_derive::Deserialize;
2420
use std::io::{self, Write};
2521
use std::str;
2622

@@ -123,7 +119,7 @@ fn run(args: &Args) -> Result<(), git2::Error> {
123119
}
124120

125121
fn main() {
126-
const USAGE: &'static str = "
122+
const USAGE: &str = "
127123
usage: fetch [options] [<remote>]
128124
129125
Options:

examples/init.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,9 @@
1414

1515
#![deny(warnings)]
1616

17-
extern crate docopt;
18-
extern crate git2;
19-
#[macro_use]
20-
extern crate serde_derive;
21-
2217
use docopt::Docopt;
2318
use git2::{Error, Repository, RepositoryInitMode, RepositoryInitOptions};
19+
use serde_derive::Deserialize;
2420
use std::path::{Path, PathBuf};
2521

2622
#[derive(Deserialize)]
@@ -129,7 +125,7 @@ fn parse_shared(shared: &str) -> Result<RepositoryInitMode, Error> {
129125
}
130126

131127
fn main() {
132-
const USAGE: &'static str = "
128+
const USAGE: &str = "
133129
usage: init [options] <directory>
134130
135131
Options:

examples/log.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,10 @@
1414

1515
#![deny(warnings)]
1616

17-
#[macro_use]
18-
extern crate serde_derive;
19-
extern crate docopt;
20-
extern crate git2;
21-
extern crate time;
22-
2317
use docopt::Docopt;
2418
use git2::{Commit, DiffOptions, ObjectType, Repository, Signature, Time};
2519
use git2::{DiffFormat, Error, Pathspec};
20+
use serde_derive::Deserialize;
2621
use std::str;
2722

2823
#[derive(Deserialize)]
@@ -274,7 +269,7 @@ impl Args {
274269
}
275270

276271
fn main() {
277-
const USAGE: &'static str = "
272+
const USAGE: &str = "
278273
usage: log [options] [<commit>..] [--] [<spec>..]
279274
280275
Options:

examples/ls-remote.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,9 @@
1414

1515
#![deny(warnings)]
1616

17-
extern crate docopt;
18-
extern crate git2;
19-
#[macro_use]
20-
extern crate serde_derive;
21-
2217
use docopt::Docopt;
2318
use git2::{Direction, Repository};
19+
use serde_derive::Deserialize;
2420

2521
#[derive(Deserialize)]
2622
struct Args {
@@ -47,7 +43,7 @@ fn run(args: &Args) -> Result<(), git2::Error> {
4743
}
4844

4945
fn main() {
50-
const USAGE: &'static str = "
46+
const USAGE: &str = "
5147
usage: ls-remote [option] <remote>
5248
5349
Options:

examples/rev-list.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,9 @@
1515

1616
#![deny(warnings)]
1717

18-
extern crate docopt;
19-
extern crate git2;
20-
#[macro_use]
21-
extern crate serde_derive;
22-
2318
use docopt::Docopt;
2419
use git2::{Error, Oid, Repository, Revwalk};
20+
use serde_derive::Deserialize;
2521

2622
#[derive(Deserialize)]
2723
struct Args {
@@ -93,7 +89,7 @@ fn push(revwalk: &mut Revwalk, id: Oid, hide: bool) -> Result<(), Error> {
9389
}
9490

9591
fn main() {
96-
const USAGE: &'static str = "
92+
const USAGE: &str = "
9793
usage: rev-list [options] [--] <spec>...
9894
9995
Options:

examples/rev-parse.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,9 @@
1414

1515
#![deny(warnings)]
1616

17-
extern crate docopt;
18-
extern crate git2;
19-
#[macro_use]
20-
extern crate serde_derive;
21-
2217
use docopt::Docopt;
2318
use git2::Repository;
19+
use serde_derive::Deserialize;
2420

2521
#[derive(Deserialize)]
2622
struct Args {
@@ -54,7 +50,7 @@ fn run(args: &Args) -> Result<(), git2::Error> {
5450
}
5551

5652
fn main() {
57-
const USAGE: &'static str = "
53+
const USAGE: &str = "
5854
usage: rev-parse [options] <spec>
5955
6056
Options:

examples/status.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,9 @@
1414

1515
#![deny(warnings)]
1616

17-
extern crate docopt;
18-
extern crate git2;
19-
#[macro_use]
20-
extern crate serde_derive;
21-
2217
use docopt::Docopt;
2318
use git2::{Error, ErrorCode, Repository, StatusOptions, SubmoduleIgnore};
19+
use serde_derive::Deserialize;
2420
use std::str;
2521
use std::time::Duration;
2622

@@ -415,7 +411,7 @@ impl Args {
415411
}
416412

417413
fn main() {
418-
const USAGE: &'static str = "
414+
const USAGE: &str = "
419415
usage: status [options] [--] [<spec>..]
420416
421417
Options:

examples/tag.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,9 @@
1414

1515
#![deny(warnings)]
1616

17-
extern crate docopt;
18-
extern crate git2;
19-
#[macro_use]
20-
extern crate serde_derive;
21-
2217
use docopt::Docopt;
2318
use git2::{Commit, Error, Repository, Tag};
19+
use serde_derive::Deserialize;
2420
use std::str;
2521

2622
#[derive(Deserialize)]
@@ -80,7 +76,7 @@ fn print_tag(tag: &Tag, args: &Args) {
8076
if args.flag_n.is_some() {
8177
print_list_lines(tag.message(), args);
8278
} else {
83-
println!("");
79+
println!();
8480
}
8581
}
8682

@@ -89,7 +85,7 @@ fn print_commit(commit: &Commit, name: &str, args: &Args) {
8985
if args.flag_n.is_some() {
9086
print_list_lines(commit.message(), args);
9187
} else {
92-
println!("");
88+
println!();
9389
}
9490
}
9591

@@ -106,15 +102,15 @@ fn print_list_lines(message: Option<&str>, args: &Args) {
106102
if let Some(first) = lines.next() {
107103
print!("{}", first);
108104
}
109-
println!("");
105+
println!();
110106

111107
for line in lines.take(args.flag_n.unwrap_or(0) as usize) {
112108
print!(" {}", line);
113109
}
114110
}
115111

116112
fn main() {
117-
const USAGE: &'static str = "
113+
const USAGE: &str = "
118114
usage:
119115
tag [-a] [-f] [-m <msg>] <tagname> [<object>]
120116
tag -d <tag>

0 commit comments

Comments
 (0)