diff --git a/src/built_in_identifiers.rs b/src/built_in_identifiers.rs index c6f5061..8659ad5 100644 --- a/src/built_in_identifiers.rs +++ b/src/built_in_identifiers.rs @@ -10,22 +10,42 @@ pub fn all_built_in_identifiers() -> impl Iterator { static OPTION: OnceLock = OnceLock::new(); static NONE: OnceLock = OnceLock::new(); +static SOME: OnceLock = OnceLock::new(); +static RESULT: OnceLock = OnceLock::new(); +static OK: OnceLock = OnceLock::new(); +static ERROR: OnceLock = OnceLock::new(); #[derive(Sequence, Debug)] pub enum BuiltInIdentifier { Option, None, + Some, + Result, + Ok, + Error, } impl BuiltInIdentifier { - pub fn get(&self) -> Identifier { + pub fn get(&self) -> &Identifier { match self { - BuiltInIdentifier::Option => OPTION - .get_or_init(|| Identifier::from_raw_parts(Arc::new("Option".to_string()))) - .clone(), - BuiltInIdentifier::None => NONE - .get_or_init(|| Identifier::from_raw_parts(Arc::new("None".to_string()))) - .clone(), + BuiltInIdentifier::Option => { + OPTION.get_or_init(|| Identifier::from_raw_parts(Arc::new("Option".to_string()))) + } + BuiltInIdentifier::None => { + NONE.get_or_init(|| Identifier::from_raw_parts(Arc::new("None".to_string()))) + } + BuiltInIdentifier::Some => { + SOME.get_or_init(|| Identifier::from_raw_parts(Arc::new("Some".to_string()))) + } + BuiltInIdentifier::Result => { + RESULT.get_or_init(|| Identifier::from_raw_parts(Arc::new("Result".to_string()))) + } + BuiltInIdentifier::Ok => { + OK.get_or_init(|| Identifier::from_raw_parts(Arc::new("Ok".to_string()))) + } + BuiltInIdentifier::Error => { + ERROR.get_or_init(|| Identifier::from_raw_parts(Arc::new("Error".to_string()))) + } } } } diff --git a/src/value/mod.rs b/src/value/mod.rs index 2b256dd..7249521 100644 --- a/src/value/mod.rs +++ b/src/value/mod.rs @@ -35,16 +35,16 @@ pub mod struct_instance; /// value that can be treated as any other. #[derive(Debug, Clone)] pub enum Value { + Boolean(bool), + Enum(EnumInstance), + Float(f64), + Function(Function), + Integer(i64), List(List), Map(Map), - Function(Function), - String(String), - Float(f64), - Integer(i64), - Boolean(bool), Range(RangeInclusive), + String(String), Struct(StructInstance), - Enum(EnumInstance), } impl Value {