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

Commit f0145fb

Browse files
committed
style: Adjust for rustfmt
1 parent 230ecac commit f0145fb

File tree

2 files changed

+39
-32
lines changed

2 files changed

+39
-32
lines changed

src/assert.rs

+16-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1+
use environment::Environment;
2+
use error_chain::ChainedError;
3+
use errors::*;
4+
use output::{Content, Output, OutputKind, OutputPredicate};
15
use std::default;
26
use std::ffi::{OsStr, OsString};
37
use std::io::Write;
48
use std::path::PathBuf;
59
use std::process::{Command, Stdio};
610
use std::vec::Vec;
711

8-
use environment::Environment;
9-
use error_chain::ChainedError;
10-
11-
use errors::*;
12-
use output::{Content, Output, OutputKind, OutputPredicate};
13-
1412
/// Assertions for a specific command.
1513
#[derive(Debug)]
1614
#[must_use]
@@ -377,7 +375,10 @@ impl Assert {
377375

378376
self.expect_output
379377
.iter()
380-
.map(|a| a.verify(&output).chain_err(|| ErrorKind::AssertionFailed(self.cmd.clone())))
378+
.map(|a| {
379+
a.verify(&output)
380+
.chain_err(|| ErrorKind::AssertionFailed(self.cmd.clone()))
381+
})
381382
.collect::<Result<Vec<()>>>()?;
382383

383384
Ok(())
@@ -490,8 +491,9 @@ impl OutputAssertionBuilder {
490491
/// .unwrap();
491492
/// ```
492493
pub fn satisfies<F, M>(mut self, pred: F, msg: M) -> Assert
493-
where F: 'static + Fn(&str) -> bool,
494-
M: Into<String>
494+
where
495+
F: 'static + Fn(&str) -> bool,
496+
M: Into<String>,
495497
{
496498
let pred = OutputPredicate::new(self.kind, Output::satisfies(pred, msg));
497499
self.assertion.expect_output.push(pred);
@@ -512,7 +514,11 @@ mod test {
512514
fn take_ownership() {
513515
let x = Environment::inherit();
514516

515-
command().with_env(x.clone()).with_env(&x).with_env(x).unwrap();
517+
command()
518+
.with_env(x.clone())
519+
.with_env(&x)
520+
.with_env(x)
521+
.unwrap();
516522
}
517523

518524
#[test]

src/output.rs

+23-22
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1+
use self::errors::*;
2+
pub use self::errors::{Error, ErrorKind};
3+
use diff;
4+
use difference::Changeset;
15
use std::fmt;
26
use std::process;
37
use std::rc;
48

5-
use difference::Changeset;
6-
7-
use diff;
8-
use self::errors::*;
9-
pub use self::errors::{Error, ErrorKind};
10-
119

1210
#[derive(Clone, PartialEq, Eq)]
1311
pub enum Content {
@@ -24,15 +22,13 @@ impl fmt::Debug for Content {
2422
}
2523
}
2624

27-
impl<'a> From<&'a str> for Content
28-
{
25+
impl<'a> From<&'a str> for Content {
2926
fn from(data: &'a str) -> Self {
3027
Content::Str(data.into())
3128
}
3229
}
3330

34-
impl<'a> From<&'a [u8]> for Content
35-
{
31+
impl<'a> From<&'a [u8]> for Content {
3632
fn from(data: &'a [u8]) -> Self {
3733
Content::Bytes(data.into())
3834
}
@@ -47,7 +43,9 @@ struct IsPredicate {
4743
impl IsPredicate {
4844
pub fn verify(&self, got: &[u8]) -> Result<()> {
4945
match self.expect {
50-
Content::Str(ref expect) => self.verify_str(expect, String::from_utf8_lossy(got).as_ref()),
46+
Content::Str(ref expect) => {
47+
self.verify_str(expect, String::from_utf8_lossy(got).as_ref())
48+
}
5149
Content::Bytes(ref expect) => self.verify_bytes(expect, got),
5250
}
5351
}
@@ -97,7 +95,9 @@ struct ContainsPredicate {
9795
}
9896

9997
fn find_subsequence(haystack: &[u8], needle: &[u8]) -> Option<usize> {
100-
haystack.windows(needle.len()).position(|window| window == needle)
98+
haystack
99+
.windows(needle.len())
100+
.position(|window| window == needle)
101101
}
102102

103103
#[test]
@@ -109,7 +109,9 @@ fn test_find_subsequence() {
109109
impl ContainsPredicate {
110110
pub fn verify(&self, got: &[u8]) -> Result<()> {
111111
match self.expect {
112-
Content::Str(ref expect) => self.verify_str(expect, String::from_utf8_lossy(got).as_ref()),
112+
Content::Str(ref expect) => {
113+
self.verify_str(expect, String::from_utf8_lossy(got).as_ref())
114+
}
113115
Content::Bytes(ref expect) => self.verify_bytes(expect, got),
114116
}
115117
}
@@ -157,8 +159,9 @@ impl FnPredicate {
157159
pub fn verify(&self, got: &[u8]) -> Result<()> {
158160
let got = String::from_utf8_lossy(got);
159161
let pred = &self.pred;
160-
if ! pred(&got) {
161-
bail!(ErrorKind::PredicateFailed(got.into_owned(), self.msg.clone()));
162+
if !pred(&got) {
163+
let err: Error = ErrorKind::PredicateFailed(got.into_owned(), self.msg.clone()).into();
164+
bail!(err);
162165
}
163166

164167
Ok(())
@@ -175,7 +178,7 @@ impl fmt::Debug for FnPredicate {
175178
enum ContentPredicate {
176179
Is(IsPredicate),
177180
Contains(ContainsPredicate),
178-
Fn(FnPredicate),
181+
Fn(FnPredicate),
179182
}
180183

181184
impl ContentPredicate {
@@ -287,8 +290,9 @@ impl Output {
287290
/// .unwrap();
288291
/// ```
289292
pub fn satisfies<F, M>(pred: F, msg: M) -> Self
290-
where F: 'static + Fn(&str) -> bool,
291-
M: Into<String>
293+
where
294+
F: 'static + Fn(&str) -> bool,
295+
M: Into<String>,
292296
{
293297
let pred = FnPredicate {
294298
pred: rc::Rc::new(pred),
@@ -329,10 +333,7 @@ pub struct OutputPredicate {
329333

330334
impl OutputPredicate {
331335
pub fn new(kind: OutputKind, pred: Output) -> Self {
332-
Self {
333-
kind,
334-
pred,
335-
}
336+
Self { kind, pred }
336337
}
337338

338339
pub(crate) fn verify(&self, got: &process::Output) -> Result<()> {

0 commit comments

Comments
 (0)