use std::error::Error;
use std::fmt;
use std::result;
use std::num::ParseFloatError;
pub type Result<T> = result::Result<T, TinyExprError>;
#[derive(Debug)]
pub enum TinyExprError {
Parse(ParseFloatError),
Other(String)
}
impl fmt::Display for TinyExprError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
TinyExprError::Parse(ref err) => err.fmt(f),
TinyExprError::Other(ref err) => err.fmt(f)
}
}
}
impl Error for TinyExprError {
fn description(&self) -> &str {
match *self {
TinyExprError::Parse(ref err) => err.description(),
TinyExprError::Other(ref err) => err
}
}
}
impl From<String> for TinyExprError {
fn from(err: String) -> TinyExprError {
TinyExprError::Other(err)
}
}
impl From<ParseFloatError> for TinyExprError {
fn from(err: ParseFloatError) -> TinyExprError {
TinyExprError::Parse(err)
}
}