mirror of
https://github.com/tiffany352/rink-rs
synced 2024-11-10 05:34:14 +00:00
Simplify some matches
This commit is contained in:
parent
31897c48c1
commit
1ce838983d
4 changed files with 7 additions and 13 deletions
|
@ -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
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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());
|
||||
|
|
Loading…
Reference in a new issue