libstd: Prefer Option::map
/etc over match
where applicable
This commit is contained in:
parent
8dbbd81f7e
commit
4f3ab4986e
3 changed files with 6 additions and 13 deletions
|
@ -53,10 +53,7 @@ impl<'a> Parser<'a> {
|
||||||
F: FnOnce(&mut Parser) -> Option<T>,
|
F: FnOnce(&mut Parser) -> Option<T>,
|
||||||
{
|
{
|
||||||
self.read_atomically(move |p| {
|
self.read_atomically(move |p| {
|
||||||
match cb(p) {
|
cb(p).filter(|_| p.is_eof())
|
||||||
Some(x) => if p.is_eof() {Some(x)} else {None},
|
|
||||||
None => None,
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1065,10 +1065,7 @@ impl<'a> Iterator for Ancestors<'a> {
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
let next = self.next;
|
let next = self.next;
|
||||||
self.next = match next {
|
self.next = next.and_then(Path::parent);
|
||||||
Some(path) => path.parent(),
|
|
||||||
None => None,
|
|
||||||
};
|
|
||||||
next
|
next
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,16 +156,15 @@ pub fn log_enabled() -> Option<PrintFormat> {
|
||||||
_ => return Some(PrintFormat::Full),
|
_ => return Some(PrintFormat::Full),
|
||||||
}
|
}
|
||||||
|
|
||||||
let val = match env::var_os("RUST_BACKTRACE") {
|
let val = env::var_os("RUST_BACKTRACE").and_then(|x|
|
||||||
Some(x) => if &x == "0" {
|
if &x == "0" {
|
||||||
None
|
None
|
||||||
} else if &x == "full" {
|
} else if &x == "full" {
|
||||||
Some(PrintFormat::Full)
|
Some(PrintFormat::Full)
|
||||||
} else {
|
} else {
|
||||||
Some(PrintFormat::Short)
|
Some(PrintFormat::Short)
|
||||||
},
|
}
|
||||||
None => None,
|
);
|
||||||
};
|
|
||||||
ENABLED.store(match val {
|
ENABLED.store(match val {
|
||||||
Some(v) => v as isize,
|
Some(v) => v as isize,
|
||||||
None => 1,
|
None => 1,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue