Fix clippy::or_fun_call

This commit is contained in:
Alan Du 2019-06-03 10:27:51 -04:00
parent 40424d4222
commit b28ca32db2
12 changed files with 29 additions and 26 deletions

View file

@ -105,17 +105,15 @@ impl Bindings {
}
fn get(&self, name: &SmolStr, nesting: &[usize]) -> Result<&tt::TokenTree, ExpandError> {
let mut b = self
.inner
.get(name)
.ok_or(ExpandError::BindingError(format!("could not find binding `{}`", name)))?;
let mut b = self.inner.get(name).ok_or_else(|| {
ExpandError::BindingError(format!("could not find binding `{}`", name))
})?;
for &idx in nesting.iter() {
b = match b {
Binding::Simple(_) => break,
Binding::Nested(bs) => bs.get(idx).ok_or(ExpandError::BindingError(format!(
"could not find nested binding `{}`",
name
)))?,
Binding::Nested(bs) => bs.get(idx).ok_or_else(|| {
ExpandError::BindingError(format!("could not find nested binding `{}`", name))
})?,
Binding::Empty => {
return Err(ExpandError::BindingError(format!(
"could not find empty binding `{}`",

View file

@ -125,8 +125,8 @@ fn parse_repeat(p: &mut TtCursor, transcriber: bool) -> Result<crate::Repeat, Pa
}
}
let sep = p.eat_seperator().ok_or(ParseError::Expected(String::from("separator")))?;
let rep = p.eat_punct().ok_or(ParseError::Expected(String::from("repeat")))?;
let sep = p.eat_seperator().ok_or_else(|| ParseError::Expected(String::from("separator")))?;
let rep = p.eat_punct().ok_or_else(|| ParseError::Expected(String::from("repeat")))?;
mk_repeat(rep.char, subtree, Some(sep))
}