Skip to content

Commit ca02573

Browse files
committed
Some tiny refactors
1 parent ead0fc9 commit ca02573

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

src/formatting.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,7 @@ fn should_skip_module<T: FormatHandler>(
9191
}
9292

9393
fn echo_back_stdin(input: &str) -> Result<FormatReport, ErrorKind> {
94-
if let Err(e) = io::stdout().write_all(input.as_bytes()) {
95-
return Err(From::from(e));
96-
}
94+
io::stdout().write_all(input.as_bytes())?;
9795
Ok(FormatReport::new())
9896
}
9997

src/test/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,8 @@ fn idempotent_check(
751751

752752
let target = sig_comments.get("target").map(|x| &(*x)[..]);
753753

754-
handle_result(write_result, target).map(|_| format_report)
754+
handle_result(write_result, target)?;
755+
Ok(format_report)
755756
}
756757

757758
// Reads test config file using the supplied (optional) file name. If there's no file name or the

src/visitor.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -872,8 +872,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
872872
// Extract leading `use ...;`.
873873
let items: Vec<_> = stmts
874874
.iter()
875-
.take_while(|stmt| stmt.to_item().map_or(false, is_use_item))
876-
.filter_map(|stmt| stmt.to_item())
875+
.map_while(|stmt| stmt.to_item().filter(|i| is_use_item(i)))
877876
.collect();
878877

879878
if items.is_empty() {

0 commit comments

Comments
 (0)