Skip to content

Instantly share code, notes, and snippets.

@QuietMisdreavus
Last active July 21, 2016 17:41
Show Gist options
  • Save QuietMisdreavus/58abe912e50828b494716e9ead446db3 to your computer and use it in GitHub Desktop.
Save QuietMisdreavus/58abe912e50828b494716e9ead446db3 to your computer and use it in GitHub Desktop.
//i have kv, an iterator over a str.split call, whose next value is the value i'm working on
//in this match arm, i want to take the value and make it an i64
try!(i64::from_str_radix(try!(kv.next().ok_or(error::Error::InvalidResponse)), 10).or(Err(error::Error::InvalidResponse)))
//oh wait, never mind, i need an Option<i64> anyway, and i'll try! it anyway further down, so this is much nicer
kv.next().and_then(|s| i64::from_str_radix(s, 10).ok())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment