From d51a9a73d709bb32b04a17d239ab968281b78df8 Mon Sep 17 00:00:00 2001 From: greg Date: Thu, 22 Feb 2018 00:31:13 -0800 Subject: [PATCH] Simplified match --- src/schala_lang/typechecking.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/schala_lang/typechecking.rs b/src/schala_lang/typechecking.rs index 98c122a..a100946 100644 --- a/src/schala_lang/typechecking.rs +++ b/src/schala_lang/typechecking.rs @@ -20,7 +20,6 @@ pub enum TConst { Custom(String), } - type TypeResult = Result; impl TypeContext { @@ -77,12 +76,12 @@ impl TypeContext { Ok(match anno { &Tuple(_) => return Err(format!("Tuples not yet implemented")), &Singleton(ref name) => match name { - &TypeSingletonName { ref name, .. } => match **name { - ref n if n == "Int" => Const(Int), - ref n if n == "Float" => Const(Float), - ref n if n == "Bool" => Const(Bool), - ref n if n == "String" => Const(StringT), - ref n => Const(Custom((format!("{}", n)))) + &TypeSingletonName { ref name, .. } => match &name[..] { + "Int" => Const(Int), + "Float" => Const(Float), + "Bool" => Const(Bool), + "String" => Const(StringT), + n => Const(Custom(n.to_string())) } } })