Skip to content

Commit 221be29

Browse files
authored
Merge pull request #83 from epage/clean
style: Update to 2018 edition
2 parents edbded4 + 2ea9f3d commit 221be29

File tree

11 files changed

+57
-70
lines changed

11 files changed

+57
-70
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ documentation = "http://docs.rs/assert_cmd/"
1010
readme = "README.md"
1111
categories = ["development-tools::testing"]
1212
keywords = ["cli", "test", "assert", "command", "duct"]
13+
edition = "2018"
1314

1415
[[bin]]
1516
name = "bin_fixture"

examples/example_fixture.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::io;
44
use std::io::Write;
55
use std::process;
66

7-
fn run() -> Result<(), Box<Error>> {
7+
fn run() -> Result<(), Box<dyn Error>> {
88
if let Ok(text) = env::var("stdout") {
99
println!("{}", text);
1010
}

src/assert.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use predicates::str::PredicateStrExt;
1111
use predicates_core;
1212
use predicates_tree::CaseTreeExt;
1313

14-
use cmd::dump_buffer;
15-
use cmd::output_fmt;
14+
use crate::cmd::dump_buffer;
15+
use crate::cmd::output_fmt;
1616

1717
/// Assert the state of an [`Output`].
1818
///
@@ -84,7 +84,7 @@ impl<'c> OutputAssertExt for &'c mut process::Command {
8484
/// [`OutputAssertExt`]: trait.OutputAssertExt.html
8585
pub struct Assert {
8686
output: process::Output,
87-
context: Vec<(&'static str, Box<fmt::Display>)>,
87+
context: Vec<(&'static str, Box<dyn fmt::Display>)>,
8888
}
8989

9090
impl Assert {
@@ -252,7 +252,7 @@ impl Assert {
252252
self.code_impl(&pred.into_code())
253253
}
254254

255-
fn code_impl(self, pred: &predicates_core::Predicate<i32>) -> Self {
255+
fn code_impl(self, pred: &dyn predicates_core::Predicate<i32>) -> Self {
256256
let actual_code = self
257257
.output
258258
.status
@@ -346,7 +346,7 @@ impl Assert {
346346
self.stdout_impl(&pred.into_output())
347347
}
348348

349-
fn stdout_impl(self, pred: &predicates_core::Predicate<[u8]>) -> Self {
349+
fn stdout_impl(self, pred: &dyn predicates_core::Predicate<[u8]>) -> Self {
350350
{
351351
let actual = &self.output.stdout;
352352
if let Some(case) = pred.find_case(false, &actual) {
@@ -438,7 +438,7 @@ impl Assert {
438438
self.stderr_impl(&pred.into_output())
439439
}
440440

441-
fn stderr_impl(self, pred: &predicates_core::Predicate<[u8]>) -> Self {
441+
fn stderr_impl(self, pred: &dyn predicates_core::Predicate<[u8]>) -> Self {
442442
{
443443
let actual = &self.output.stderr;
444444
if let Some(case) = pred.find_case(false, &actual) {
@@ -450,7 +450,7 @@ impl Assert {
450450
}
451451

452452
impl fmt::Display for Assert {
453-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
453+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
454454
for &(ref name, ref context) in &self.context {
455455
writeln!(f, "{}=`{}`", name, context)?;
456456
}
@@ -459,7 +459,7 @@ impl fmt::Display for Assert {
459459
}
460460

461461
impl fmt::Debug for Assert {
462-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
462+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
463463
f.debug_struct("Assert")
464464
.field("output", &self.output)
465465
.finish()
@@ -550,12 +550,12 @@ impl EqCodePredicate {
550550
impl predicates_core::reflection::PredicateReflection for EqCodePredicate {
551551
fn parameters<'a>(
552552
&'a self,
553-
) -> Box<Iterator<Item = predicates_core::reflection::Parameter<'a>> + 'a> {
553+
) -> Box<dyn Iterator<Item = predicates_core::reflection::Parameter<'a>> + 'a> {
554554
self.0.parameters()
555555
}
556556

557557
/// Nested `Predicate`s of the current `Predicate`.
558-
fn children<'a>(&'a self) -> Box<Iterator<Item = predicates_core::reflection::Child<'a>> + 'a> {
558+
fn children<'a>(&'a self) -> Box<dyn Iterator<Item = predicates_core::reflection::Child<'a>> + 'a> {
559559
self.0.children()
560560
}
561561
}
@@ -575,7 +575,7 @@ impl predicates_core::Predicate<i32> for EqCodePredicate {
575575
}
576576

577577
impl fmt::Display for EqCodePredicate {
578-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
578+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
579579
self.0.fmt(f)
580580
}
581581
}
@@ -620,12 +620,12 @@ impl InCodePredicate {
620620
impl predicates_core::reflection::PredicateReflection for InCodePredicate {
621621
fn parameters<'a>(
622622
&'a self,
623-
) -> Box<Iterator<Item = predicates_core::reflection::Parameter<'a>> + 'a> {
623+
) -> Box<dyn Iterator<Item = predicates_core::reflection::Parameter<'a>> + 'a> {
624624
self.0.parameters()
625625
}
626626

627627
/// Nested `Predicate`s of the current `Predicate`.
628-
fn children<'a>(&'a self) -> Box<Iterator<Item = predicates_core::reflection::Child<'a>> + 'a> {
628+
fn children<'a>(&'a self) -> Box<dyn Iterator<Item = predicates_core::reflection::Child<'a>> + 'a> {
629629
self.0.children()
630630
}
631631
}
@@ -645,7 +645,7 @@ impl predicates_core::Predicate<i32> for InCodePredicate {
645645
}
646646

647647
impl fmt::Display for InCodePredicate {
648-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
648+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
649649
self.0.fmt(f)
650650
}
651651
}
@@ -754,12 +754,12 @@ impl BytesContentOutputPredicate {
754754
impl predicates_core::reflection::PredicateReflection for BytesContentOutputPredicate {
755755
fn parameters<'a>(
756756
&'a self,
757-
) -> Box<Iterator<Item = predicates_core::reflection::Parameter<'a>> + 'a> {
757+
) -> Box<dyn Iterator<Item = predicates_core::reflection::Parameter<'a>> + 'a> {
758758
self.0.parameters()
759759
}
760760

761761
/// Nested `Predicate`s of the current `Predicate`.
762-
fn children<'a>(&'a self) -> Box<Iterator<Item = predicates_core::reflection::Child<'a>> + 'a> {
762+
fn children<'a>(&'a self) -> Box<dyn Iterator<Item = predicates_core::reflection::Child<'a>> + 'a> {
763763
self.0.children()
764764
}
765765
}
@@ -779,7 +779,7 @@ impl predicates_core::Predicate<[u8]> for BytesContentOutputPredicate {
779779
}
780780

781781
impl fmt::Display for BytesContentOutputPredicate {
782-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
782+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
783783
self.0.fmt(f)
784784
}
785785
}
@@ -833,12 +833,12 @@ impl StrContentOutputPredicate {
833833
impl predicates_core::reflection::PredicateReflection for StrContentOutputPredicate {
834834
fn parameters<'a>(
835835
&'a self,
836-
) -> Box<Iterator<Item = predicates_core::reflection::Parameter<'a>> + 'a> {
836+
) -> Box<dyn Iterator<Item = predicates_core::reflection::Parameter<'a>> + 'a> {
837837
self.0.parameters()
838838
}
839839

840840
/// Nested `Predicate`s of the current `Predicate`.
841-
fn children<'a>(&'a self) -> Box<Iterator<Item = predicates_core::reflection::Child<'a>> + 'a> {
841+
fn children<'a>(&'a self) -> Box<dyn Iterator<Item = predicates_core::reflection::Child<'a>> + 'a> {
842842
self.0.children()
843843
}
844844
}
@@ -858,7 +858,7 @@ impl predicates_core::Predicate<[u8]> for StrContentOutputPredicate {
858858
}
859859

860860
impl fmt::Display for StrContentOutputPredicate {
861-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
861+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
862862
self.0.fmt(f)
863863
}
864864
}
@@ -924,12 +924,12 @@ where
924924
{
925925
fn parameters<'a>(
926926
&'a self,
927-
) -> Box<Iterator<Item = predicates_core::reflection::Parameter<'a>> + 'a> {
927+
) -> Box<dyn Iterator<Item = predicates_core::reflection::Parameter<'a>> + 'a> {
928928
self.0.parameters()
929929
}
930930

931931
/// Nested `Predicate`s of the current `Predicate`.
932-
fn children<'a>(&'a self) -> Box<Iterator<Item = predicates_core::reflection::Child<'a>> + 'a> {
932+
fn children<'a>(&'a self) -> Box<dyn Iterator<Item = predicates_core::reflection::Child<'a>> + 'a> {
933933
self.0.children()
934934
}
935935
}
@@ -955,7 +955,7 @@ impl<P> fmt::Display for StrOutputPredicate<P>
955955
where
956956
P: predicates_core::Predicate<str>,
957957
{
958-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
958+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
959959
self.0.fmt(f)
960960
}
961961
}

src/bin/bin_fixture.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::io;
44
use std::io::Write;
55
use std::process;
66

7-
fn run() -> Result<(), Box<Error>> {
7+
fn run() -> Result<(), Box<dyn Error>> {
88
if let Ok(text) = env::var("stdout") {
99
println!("{}", text);
1010
}

src/cargo.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl CommandCargoExt for process::Command {
138138
/// Error when finding crate binary.
139139
#[derive(Debug)]
140140
pub struct CargoError {
141-
cause: Option<Box<Error + Send + Sync + 'static>>,
141+
cause: Option<Box<dyn Error + Send + Sync + 'static>>,
142142
}
143143

144144
impl CargoError {
@@ -157,16 +157,16 @@ impl Error for CargoError {
157157
"Cargo command failed."
158158
}
159159

160-
fn cause(&self) -> Option<&Error> {
160+
fn cause(&self) -> Option<&dyn Error> {
161161
self.cause.as_ref().map(|c| {
162-
let c: &Error = c.as_ref();
162+
let c: &dyn Error = c.as_ref();
163163
c
164164
})
165165
}
166166
}
167167

168168
impl fmt::Display for CargoError {
169-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
169+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
170170
if let Some(ref cause) = self.cause {
171171
writeln!(f, "Cause: {}", cause)?;
172172
}
@@ -185,13 +185,13 @@ impl Error for NotFoundError {
185185
"Cargo command not found."
186186
}
187187

188-
fn cause(&self) -> Option<&Error> {
188+
fn cause(&self) -> Option<&dyn Error> {
189189
None
190190
}
191191
}
192192

193193
impl fmt::Display for NotFoundError {
194-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
194+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
195195
writeln!(f, "Cargo command not found: {}", self.path.display())
196196
}
197197
}

src/cmd.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ impl Error for OutputError {
247247
"Command failed."
248248
}
249249

250-
fn cause(&self) -> Option<&Error> {
250+
fn cause(&self) -> Option<&dyn Error> {
251251
if let OutputCause::Unexpected(ref err) = self.cause {
252252
Some(err.as_ref())
253253
} else {
@@ -257,7 +257,7 @@ impl Error for OutputError {
257257
}
258258

259259
impl fmt::Display for OutputError {
260-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
260+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
261261
if let Some(ref cmd) = self.cmd {
262262
writeln!(f, "command=`{}`", cmd)?;
263263
}
@@ -275,11 +275,11 @@ impl fmt::Display for OutputError {
275275
#[derive(Debug)]
276276
enum OutputCause {
277277
Expected(Output),
278-
Unexpected(Box<Error + Send + Sync + 'static>),
278+
Unexpected(Box<dyn Error + Send + Sync + 'static>),
279279
}
280280

281281
impl fmt::Display for OutputCause {
282-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
282+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
283283
match *self {
284284
OutputCause::Expected(ref e) => write!(f, "{}", e),
285285
OutputCause::Unexpected(ref e) => write!(f, "{}", e),
@@ -293,12 +293,12 @@ struct Output {
293293
}
294294

295295
impl fmt::Display for Output {
296-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
296+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
297297
output_fmt(&self.output, f)
298298
}
299299
}
300300

301-
pub(crate) fn output_fmt(output: &process::Output, f: &mut fmt::Formatter) -> fmt::Result {
301+
pub(crate) fn output_fmt(output: &process::Output, f: &mut fmt::Formatter<'_>) -> fmt::Result {
302302
if let Some(code) = output.status.code() {
303303
writeln!(f, "code={}", code)?;
304304
} else {
@@ -324,7 +324,7 @@ pub(crate) fn dump_buffer(buffer: &[u8]) -> String {
324324
}
325325
}
326326

327-
pub(crate) fn write_buffer(buffer: &[u8], f: &mut fmt::Formatter) -> fmt::Result {
327+
pub(crate) fn write_buffer(buffer: &[u8], f: &mut fmt::Formatter<'_>) -> fmt::Result {
328328
if let Ok(buffer) = str::from_utf8(buffer) {
329329
write!(f, "{}", buffer)
330330
} else {
@@ -344,7 +344,7 @@ impl DebugBuffer {
344344
}
345345

346346
impl fmt::Display for DebugBuffer {
347-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
347+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
348348
write_buffer(&self.buffer, f)
349349
}
350350
}

src/lib.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,6 @@
108108
109109
#![warn(missing_docs)]
110110

111-
extern crate escargot;
112-
extern crate predicates;
113-
extern crate predicates_core;
114-
extern crate predicates_tree;
115-
116111
/// Allows you to pull the name from your Cargo.toml at compile time.
117112
///
118113
/// # Examples
@@ -154,10 +149,10 @@ pub mod stdin;
154149

155150
/// Extension traits that are useful to have available.
156151
pub mod prelude {
157-
pub use assert::OutputAssertExt;
158-
pub use cargo::CommandCargoExt;
159-
pub use cmd::OutputOkExt;
160-
pub use stdin::CommandStdInExt;
152+
pub use crate::assert::OutputAssertExt;
153+
pub use crate::cargo::CommandCargoExt;
154+
pub use crate::cmd::OutputOkExt;
155+
pub use crate::stdin::CommandStdInExt;
161156
}
162157

163158
#[macro_use]

0 commit comments

Comments
 (0)