Simplify some matches

This commit is contained in:
Colin Benner 2018-11-22 15:20:24 +01:00 committed by Tiffany Bennett
parent 31897c48c1
commit 1ce838983d
4 changed files with 7 additions and 13 deletions

View file

@ -27,10 +27,9 @@ fn main_noninteractive<T: BufRead>(mut f: T, show_prompt: bool) {
print!("> ");
}
stdout().flush().unwrap();
match f.read_line(&mut line) {
Ok(_) => (),
Err(_) => return
};
if f.read_line(&mut line).is_err() {
return
}
// the underlying file object has hit an EOF if we try to read a
// line but do not find the newline at the end, so let's break
// out of the loop

View file

@ -253,10 +253,7 @@ pub fn parse_date<I>(
if advance {
date.next();
}
match res {
Ok(()) => parse_date(out, out_tz, date, &pat[1..]),
Err(e) => Err(e)
}
res.and_then(|_| parse_date(out, out_tz, date, &pat[1..]))
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]

View file

@ -98,9 +98,8 @@ impl<'a> Iterator for TokenIterator<'a> {
},
'#' => {
while let Some(c) = self.0.next() {
match c {
'\n' => break,
_ => ()
if c == '\n' {
break;
}
}
Token::Newline

View file

@ -55,8 +55,7 @@ fn root(rink: &Rink, req: &mut Request) -> IronResult<Response> {
let map = req.get_ref::<Params>().unwrap();
match map.find(&["q"]) {
Some(&Value::String(ref query)) if query == "" => (),
Some(&Value::String(ref query)) => {
Some(&Value::String(ref query)) if !query.is_empty() => {
let mut reply = eval_json(query);
reply.as_object_mut().unwrap().insert("input".to_owned(), query.to_json());
println!("{}", reply.pretty());