Skip to content
This repository was archived by the owner on Aug 16, 2021. It is now read-only.

Commit 09ba055

Browse files
dead10ckYamakaky
authored andcommitted
cargo fmt
1 parent e781ed5 commit 09ba055

File tree

10 files changed

+55
-67
lines changed

10 files changed

+55
-67
lines changed

examples/all.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
extern crate error_chain;
33

44
pub mod inner {
5-
error_chain! {}
5+
error_chain!{}
66
}
77

88
#[cfg(feature = "a_feature")]
99
pub mod feature {
10-
error_chain! {}
10+
error_chain!{}
1111
}
1212

1313
error_chain! {

examples/chain_err.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::fs::File;
99
mod errors {
1010
use std::io;
1111
use super::LaunchStage;
12-
12+
1313
error_chain! {
1414
foreign_links {
1515
Io(io::Error) #[doc = "Error during IO"];
@@ -27,7 +27,7 @@ mod errors {
2727
}
2828
}
2929
}
30-
30+
3131
impl From<LaunchStage> for ErrorKind {
3232
fn from(v: LaunchStage) -> Self {
3333
ErrorKind::Launch(v)
@@ -54,14 +54,16 @@ fn load_config(rel_path: &str) -> Result<()> {
5454
/// Launch the service.
5555
fn launch(rel_path: &str) -> Result<()> {
5656
load_config(rel_path).map_err(|e| match e {
57-
e @ Error(ErrorKind::ConfigLoad(_), _) => e.chain_err(|| LaunchStage::ConfigLoad),
58-
e => e.chain_err(|| "Unknown failure")
59-
})
57+
e @ Error(ErrorKind::ConfigLoad(_), _) => {
58+
e.chain_err(|| LaunchStage::ConfigLoad)
59+
}
60+
e => e.chain_err(|| "Unknown failure"),
61+
})
6062
}
6163

6264
fn main() {
6365
let chain = launch("does_not_exist.json").unwrap_err();
6466
for err in chain.iter() {
6567
println!("{}", err);
6668
}
67-
}
69+
}

examples/doc.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ extern crate error_chain;
77

88
/// Inner module.
99
pub mod inner {
10-
error_chain! {
11-
}
10+
error_chain!{}
1211
}
1312

1413
error_chain! {

examples/quickstart.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern crate error_chain;
1414
// `error_chain!` creates.
1515
mod errors {
1616
// Create the Error, ErrorKind, ResultExt, and Result types
17-
error_chain! { }
17+
error_chain!{}
1818
}
1919

2020
// This only gives access within this module. Make this `pub use errors::*;`
@@ -24,7 +24,7 @@ use errors::*;
2424

2525
fn main() {
2626
if let Err(ref e) = run() {
27-
use ::std::io::Write;
27+
use std::io::Write;
2828
let stderr = &mut ::std::io::stderr();
2929
let errmsg = "Error writing to stderr";
3030

examples/size.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ fn main() {
3232
}
3333
#[cfg(not(feature = "backtrace"))]
3434
{
35-
let state = error_chain::State {
36-
next_error: None,
37-
};
35+
let state = error_chain::State { next_error: None };
3836
println!(" State.next_error: {}", size_of_val(&state.next_error));
3937
}
4038
}

src/example_generated.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
2222
/// Another code generated by the macro.
2323
pub mod inner {
24-
error_chain! {}
24+
error_chain!{}
2525
}
2626

2727
error_chain! {

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@
259259
//! ## Chaining errors
260260
//! error-chain supports extending an error chain by appending new errors.
261261
//! This can be done on a Result or on an existing Error.
262-
//!
262+
//!
263263
//! To extend the error chain:
264264
//!
265265
//! ```
@@ -281,9 +281,9 @@
281281
//! boxes the original error to store as the cause, then returns a new
282282
//! error containing the original error.
283283
//!
284-
//! Calling `chain_err` on an existing `Error` instance has the same
284+
//! Calling `chain_err` on an existing `Error` instance has the same
285285
//! signature and produces the same outcome as being called on a `Result`
286-
//! matching the properties described above. This is most useful when
286+
//! matching the properties described above. This is most useful when
287287
//! partially handling errors using the `map_err` function.
288288
//!
289289
//! To chain an error directly, use `with_chain`:

src/quick_main.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,13 @@ pub trait ExitCode {
6565
}
6666

6767
impl ExitCode for i32 {
68-
fn code(self) -> i32 { self }
68+
fn code(self) -> i32 {
69+
self
70+
}
6971
}
7072

7173
impl ExitCode for () {
72-
fn code(self) -> i32 { 0 }
74+
fn code(self) -> i32 {
75+
0
76+
}
7377
}

tests/quick_main.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,5 @@ mod i32 {
2424

2525
mod closure {
2626
use super::*;
27-
quick_main!(|| -> Result<()> {
28-
Ok(())
29-
});
27+
quick_main!(|| -> Result<()> { Ok(()) });
3028
}

tests/tests.rs

Lines changed: 30 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ fn order_test_8() {
197197

198198
#[test]
199199
fn empty() {
200-
error_chain! { };
200+
error_chain!{};
201201
}
202202

203203
#[test]
@@ -251,7 +251,7 @@ fn chain_err() {
251251
let _: Result<()> = Err(Error::from_kind(ErrorKind::Test)).chain_err(|| "");
252252
}
253253

254-
/// Verify that an error chain is extended one by `Error::chain_err`, with
254+
/// Verify that an error chain is extended one by `Error::chain_err`, with
255255
/// the new error added to the end.
256256
#[test]
257257
fn error_chain_err() {
@@ -260,10 +260,10 @@ fn error_chain_err() {
260260
Test
261261
}
262262
}
263-
263+
264264
let base = Error::from(ErrorKind::Test);
265265
let ext = base.chain_err(|| "Test passes");
266-
266+
267267
if let Error(ErrorKind::Msg(_), _) = ext {
268268
// pass
269269
} else {
@@ -274,7 +274,7 @@ fn error_chain_err() {
274274
#[test]
275275
fn links() {
276276
mod test {
277-
error_chain! {}
277+
error_chain!{}
278278
}
279279

280280
error_chain! {
@@ -293,15 +293,17 @@ mod foreign_link_test {
293293
// signature of the public foreign_link_error_path
294294
#[derive(Debug)]
295295
pub struct ForeignError {
296-
cause: ForeignErrorCause
296+
cause: ForeignErrorCause,
297297
}
298298

299299
impl ::std::error::Error for ForeignError {
300300
fn description(&self) -> &'static str {
301301
"Foreign error description"
302302
}
303303

304-
fn cause(&self) -> Option<&::std::error::Error> { Some(&self.cause) }
304+
fn cause(&self) -> Option<&::std::error::Error> {
305+
Some(&self.cause)
306+
}
305307
}
306308

307309
impl fmt::Display for ForeignError {
@@ -318,7 +320,9 @@ mod foreign_link_test {
318320
"Foreign error cause description"
319321
}
320322

321-
fn cause(&self) -> Option<&::std::error::Error> { None }
323+
fn cause(&self) -> Option<&::std::error::Error> {
324+
None
325+
}
322326
}
323327

324328
impl fmt::Display for ForeignErrorCause {
@@ -342,43 +346,31 @@ mod foreign_link_test {
342346
#[test]
343347
fn display_underlying_error() {
344348
let chained_error = try_foreign_error().err().unwrap();
345-
assert_eq!(
346-
format!("{}", ForeignError{ cause: ForeignErrorCause{} }),
347-
format!("{}", chained_error)
348-
);
349+
assert_eq!(format!("{}", ForeignError { cause: ForeignErrorCause {} }),
350+
format!("{}", chained_error));
349351
}
350352

351353
#[test]
352354
fn finds_cause() {
353355
let chained_error = try_foreign_error().err().unwrap();
354-
assert_eq!(
355-
format!("{}", ForeignErrorCause{}),
356-
format!("{}", ::std::error::Error::cause(&chained_error).unwrap())
357-
);
356+
assert_eq!(format!("{}", ForeignErrorCause {}),
357+
format!("{}", ::std::error::Error::cause(&chained_error).unwrap()));
358358
}
359359

360360
#[test]
361361
fn iterates() {
362362
let chained_error = try_foreign_error().err().unwrap();
363363
let mut error_iter = chained_error.iter();
364-
assert_eq!(
365-
format!("{}", ForeignError{ cause: ForeignErrorCause{} }),
366-
format!("{}", error_iter.next().unwrap())
367-
);
368-
assert_eq!(
369-
format!("{}", ForeignErrorCause{}),
370-
format!("{}", error_iter.next().unwrap())
371-
);
372-
assert_eq!(
373-
format!("{:?}", None as Option<&::std::error::Error>),
374-
format!("{:?}", error_iter.next())
375-
);
364+
assert_eq!(format!("{}", ForeignError { cause: ForeignErrorCause {} }),
365+
format!("{}", error_iter.next().unwrap()));
366+
assert_eq!(format!("{}", ForeignErrorCause {}),
367+
format!("{}", error_iter.next().unwrap()));
368+
assert_eq!(format!("{:?}", None as Option<&::std::error::Error>),
369+
format!("{:?}", error_iter.next()));
376370
}
377371

378372
fn try_foreign_error() -> Result<()> {
379-
try!(Err(ForeignError{
380-
cause: ForeignErrorCause{}
381-
}));
373+
try!(Err(ForeignError { cause: ForeignErrorCause {} }));
382374
Ok(())
383375
}
384376
}
@@ -390,9 +382,7 @@ mod attributes_test {
390382

391383
#[cfg(not(test))]
392384
mod inner {
393-
error_chain! {
394-
395-
}
385+
error_chain!{}
396386
}
397387

398388
error_chain! {
@@ -440,7 +430,7 @@ fn without_result() {
440430
#[test]
441431
fn documentation() {
442432
mod inner {
443-
error_chain! {}
433+
error_chain!{}
444434
}
445435

446436
error_chain! {
@@ -464,13 +454,13 @@ mod multiple_error_same_mod {
464454
MyError, MyErrorKind, MyResultExt, MyResult;
465455
}
466456
}
467-
error_chain! {}
457+
error_chain!{}
468458
}
469459

470460
#[doc(test)]
471461
#[deny(dead_code)]
472462
mod allow_dead_code {
473-
error_chain! {}
463+
error_chain!{}
474464
}
475465

476466
// Make sure links actually work!
@@ -503,8 +493,7 @@ fn error_patterns() {
503493

504494
// Tuples look nice when matching errors
505495
match Error::from("Test") {
506-
Error(ErrorKind::Msg(_), _) => {
507-
}
496+
Error(ErrorKind::Msg(_), _) => {}
508497
}
509498
}
510499

@@ -607,10 +596,8 @@ fn rewrapping() {
607596
NotUnicode(_) => Err(e).chain_err(|| "env var was bork文字化ã"),
608597
});
609598

610-
assert_eq!(
611-
format!("{}", our_error_a.unwrap_err()),
612-
format!("{}", our_error_b.unwrap_err())
613-
);
599+
assert_eq!(format!("{}", our_error_a.unwrap_err()),
600+
format!("{}", our_error_b.unwrap_err()));
614601

615602
}
616603

0 commit comments

Comments
 (0)