Simplified match

This commit is contained in:
greg 2018-02-22 00:31:13 -08:00
parent fddd43b86e
commit d51a9a73d7
1 changed files with 6 additions and 7 deletions

View File

@ -20,7 +20,6 @@ pub enum TConst {
Custom(String), Custom(String),
} }
type TypeResult<T> = Result<T, String>; type TypeResult<T> = Result<T, String>;
impl TypeContext { impl TypeContext {
@ -77,12 +76,12 @@ impl TypeContext {
Ok(match anno { Ok(match anno {
&Tuple(_) => return Err(format!("Tuples not yet implemented")), &Tuple(_) => return Err(format!("Tuples not yet implemented")),
&Singleton(ref name) => match name { &Singleton(ref name) => match name {
&TypeSingletonName { ref name, .. } => match **name { &TypeSingletonName { ref name, .. } => match &name[..] {
ref n if n == "Int" => Const(Int), "Int" => Const(Int),
ref n if n == "Float" => Const(Float), "Float" => Const(Float),
ref n if n == "Bool" => Const(Bool), "Bool" => Const(Bool),
ref n if n == "String" => Const(StringT), "String" => Const(StringT),
ref n => Const(Custom((format!("{}", n)))) n => Const(Custom(n.to_string()))
} }
} }
}) })