1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
//! Utility methods, mostly for dealing with IO. use std::io::{Error, ErrorKind}; macro_rules! try_parse { ($field:expr) => { try_parse!($field, FromStr::from_str) }; ($field:expr, $from_str:path) => { match $from_str($field) { Ok(result) => Ok(result), Err(_) => Err(Error::new( ErrorKind::InvalidInput, format!("Could not parse {:?}", $field), )), }? }; } pub fn not_found(key: &str) -> Error { Error::new(ErrorKind::NotFound, format!("{} not found", key)) }