Skip to content

Commit

Permalink
libstd: Prefer Option::map/etc over match where applicable
Browse files Browse the repository at this point in the history
  • Loading branch information
Wallacoloo committed Jul 24, 2018
1 parent 8dbbd81 commit 4f3ab49
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
5 changes: 1 addition & 4 deletions src/libstd/net/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ impl<'a> Parser<'a> {
F: FnOnce(&mut Parser) -> Option<T>,
{
self.read_atomically(move |p| {
match cb(p) {
Some(x) => if p.is_eof() {Some(x)} else {None},
None => None,
}
cb(p).filter(|_| p.is_eof())
})
}

Expand Down
5 changes: 1 addition & 4 deletions src/libstd/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1065,10 +1065,7 @@ impl<'a> Iterator for Ancestors<'a> {

fn next(&mut self) -> Option<Self::Item> {
let next = self.next;
self.next = match next {
Some(path) => path.parent(),
None => None,
};
self.next = next.and_then(Path::parent);
next
}
}
Expand Down
9 changes: 4 additions & 5 deletions src/libstd/sys_common/backtrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,15 @@ pub fn log_enabled() -> Option<PrintFormat> {
_ => return Some(PrintFormat::Full),
}

let val = match env::var_os("RUST_BACKTRACE") {
Some(x) => if &x == "0" {
let val = env::var_os("RUST_BACKTRACE").and_then(|x|
if &x == "0" {
None
} else if &x == "full" {
Some(PrintFormat::Full)
} else {
Some(PrintFormat::Short)
},
None => None,
};
}
);
ENABLED.store(match val {
Some(v) => v as isize,
None => 1,
Expand Down

0 comments on commit 4f3ab49

Please sign in to comment.