Skip to content

Commit 1d06c01

Browse files
programmerjakedjc
authored andcommitted
format code
1 parent 609c5c5 commit 1d06c01

File tree

2 files changed

+61
-25
lines changed

2 files changed

+61
-25
lines changed

src/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use std::{self, error, fmt, io, str};
21
use semver::{self, Identifier};
2+
use std::{self, error, fmt, io, str};
33

44
/// The error type for this crate.
55
#[derive(Debug)]

src/lib.rs

Lines changed: 60 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ doctest!("../README.md");
6161

6262
extern crate semver;
6363
use semver::Identifier;
64+
use std::ffi::OsString;
6465
use std::process::Command;
6566
use std::{env, str};
66-
use std::ffi::OsString;
6767

6868
// Convenience re-export to allow version comparison without needing to add
6969
// semver crate.
@@ -115,7 +115,10 @@ impl VersionMeta {
115115
pub fn for_command(cmd: Command) -> Result<VersionMeta> {
116116
let mut cmd = cmd;
117117

118-
let out = cmd.arg("-vV").output().map_err(Error::CouldNotExecuteCommand)?;
118+
let out = cmd
119+
.arg("-vV")
120+
.output()
121+
.map_err(Error::CouldNotExecuteCommand)?;
119122
let out = str::from_utf8(&out.stdout)?;
120123

121124
version_meta_for(out)
@@ -218,51 +221,60 @@ fn smoketest() {
218221
#[test]
219222
fn parse_unexpected() {
220223
let res = version_meta_for(
221-
"rustc 1.0.0 (a59de37e9 2015-05-13) (built 2015-05-14)
224+
"rustc 1.0.0 (a59de37e9 2015-05-13) (built 2015-05-14)
222225
binary: rustc
223226
commit-hash: a59de37e99060162a2674e3ff45409ac73595c0e
224227
commit-date: 2015-05-13
225228
rust-birthday: 2015-05-14
226229
host: x86_64-unknown-linux-gnu
227-
release: 1.0.0");
230+
release: 1.0.0",
231+
);
228232

229233
assert!(match res {
230234
Err(Error::UnexpectedVersionFormat) => true,
231235
_ => false,
232236
});
233-
234237
}
235238

236239
#[test]
237240
fn parse_1_0_0() {
238241
let version = version_meta_for(
239-
"rustc 1.0.0 (a59de37e9 2015-05-13) (built 2015-05-14)
242+
"rustc 1.0.0 (a59de37e9 2015-05-13) (built 2015-05-14)
240243
binary: rustc
241244
commit-hash: a59de37e99060162a2674e3ff45409ac73595c0e
242245
commit-date: 2015-05-13
243246
build-date: 2015-05-14
244247
host: x86_64-unknown-linux-gnu
245-
release: 1.0.0").unwrap();
248+
release: 1.0.0",
249+
)
250+
.unwrap();
246251

247252
assert_eq!(version.semver, Version::parse("1.0.0").unwrap());
248-
assert_eq!(version.commit_hash, Some("a59de37e99060162a2674e3ff45409ac73595c0e".into()));
253+
assert_eq!(
254+
version.commit_hash,
255+
Some("a59de37e99060162a2674e3ff45409ac73595c0e".into())
256+
);
249257
assert_eq!(version.commit_date, Some("2015-05-13".into()));
250258
assert_eq!(version.build_date, Some("2015-05-14".into()));
251259
assert_eq!(version.channel, Channel::Stable);
252260
assert_eq!(version.host, "x86_64-unknown-linux-gnu");
253-
assert_eq!(version.short_version_string, "rustc 1.0.0 (a59de37e9 2015-05-13) (built 2015-05-14)");
261+
assert_eq!(
262+
version.short_version_string,
263+
"rustc 1.0.0 (a59de37e9 2015-05-13) (built 2015-05-14)"
264+
);
254265
}
255266

256-
257267
#[test]
258268
fn parse_unknown() {
259269
let version = version_meta_for(
260-
"rustc 1.3.0
270+
"rustc 1.3.0
261271
binary: rustc
262272
commit-hash: unknown
263273
commit-date: unknown
264274
host: x86_64-unknown-linux-gnu
265-
release: 1.3.0").unwrap();
275+
release: 1.3.0",
276+
)
277+
.unwrap();
266278

267279
assert_eq!(version.semver, Version::parse("1.3.0").unwrap());
268280
assert_eq!(version.commit_hash, None);
@@ -275,56 +287,80 @@ release: 1.3.0").unwrap();
275287
#[test]
276288
fn parse_nightly() {
277289
let version = version_meta_for(
278-
"rustc 1.5.0-nightly (65d5c0833 2015-09-29)
290+
"rustc 1.5.0-nightly (65d5c0833 2015-09-29)
279291
binary: rustc
280292
commit-hash: 65d5c083377645a115c4ac23a620d3581b9562b6
281293
commit-date: 2015-09-29
282294
host: x86_64-unknown-linux-gnu
283-
release: 1.5.0-nightly").unwrap();
295+
release: 1.5.0-nightly",
296+
)
297+
.unwrap();
284298

285299
assert_eq!(version.semver, Version::parse("1.5.0-nightly").unwrap());
286-
assert_eq!(version.commit_hash, Some("65d5c083377645a115c4ac23a620d3581b9562b6".into()));
300+
assert_eq!(
301+
version.commit_hash,
302+
Some("65d5c083377645a115c4ac23a620d3581b9562b6".into())
303+
);
287304
assert_eq!(version.commit_date, Some("2015-09-29".into()));
288305
assert_eq!(version.channel, Channel::Nightly);
289306
assert_eq!(version.host, "x86_64-unknown-linux-gnu");
290-
assert_eq!(version.short_version_string, "rustc 1.5.0-nightly (65d5c0833 2015-09-29)");
307+
assert_eq!(
308+
version.short_version_string,
309+
"rustc 1.5.0-nightly (65d5c0833 2015-09-29)"
310+
);
291311
}
292312

293313
#[test]
294314
fn parse_stable() {
295315
let version = version_meta_for(
296-
"rustc 1.3.0 (9a92aaf19 2015-09-15)
316+
"rustc 1.3.0 (9a92aaf19 2015-09-15)
297317
binary: rustc
298318
commit-hash: 9a92aaf19a64603b02b4130fe52958cc12488900
299319
commit-date: 2015-09-15
300320
host: x86_64-unknown-linux-gnu
301-
release: 1.3.0").unwrap();
321+
release: 1.3.0",
322+
)
323+
.unwrap();
302324

303325
assert_eq!(version.semver, Version::parse("1.3.0").unwrap());
304-
assert_eq!(version.commit_hash, Some("9a92aaf19a64603b02b4130fe52958cc12488900".into()));
326+
assert_eq!(
327+
version.commit_hash,
328+
Some("9a92aaf19a64603b02b4130fe52958cc12488900".into())
329+
);
305330
assert_eq!(version.commit_date, Some("2015-09-15".into()));
306331
assert_eq!(version.channel, Channel::Stable);
307332
assert_eq!(version.host, "x86_64-unknown-linux-gnu");
308-
assert_eq!(version.short_version_string, "rustc 1.3.0 (9a92aaf19 2015-09-15)");
333+
assert_eq!(
334+
version.short_version_string,
335+
"rustc 1.3.0 (9a92aaf19 2015-09-15)"
336+
);
309337
}
310338

311339
#[test]
312340
fn parse_1_16_0_nightly() {
313341
let version = version_meta_for(
314-
"rustc 1.16.0-nightly (5d994d8b7 2017-01-05)
342+
"rustc 1.16.0-nightly (5d994d8b7 2017-01-05)
315343
binary: rustc
316344
commit-hash: 5d994d8b7e482e87467d4a521911477bd8284ce3
317345
commit-date: 2017-01-05
318346
host: x86_64-unknown-linux-gnu
319347
release: 1.16.0-nightly
320-
LLVM version: 3.9").unwrap();
348+
LLVM version: 3.9",
349+
)
350+
.unwrap();
321351

322352
assert_eq!(version.semver, Version::parse("1.16.0-nightly").unwrap());
323-
assert_eq!(version.commit_hash, Some("5d994d8b7e482e87467d4a521911477bd8284ce3".into()));
353+
assert_eq!(
354+
version.commit_hash,
355+
Some("5d994d8b7e482e87467d4a521911477bd8284ce3".into())
356+
);
324357
assert_eq!(version.commit_date, Some("2017-01-05".into()));
325358
assert_eq!(version.channel, Channel::Nightly);
326359
assert_eq!(version.host, "x86_64-unknown-linux-gnu");
327-
assert_eq!(version.short_version_string, "rustc 1.16.0-nightly (5d994d8b7 2017-01-05)");
360+
assert_eq!(
361+
version.short_version_string,
362+
"rustc 1.16.0-nightly (5d994d8b7 2017-01-05)"
363+
);
328364
}
329365

330366
/*

0 commit comments

Comments
 (0)