2024-02-15 21:30:47 +00:00
|
|
|
use std::sync::{Arc, OnceLock};
|
2024-02-15 20:20:29 +00:00
|
|
|
|
|
|
|
use enum_iterator::{all, Sequence};
|
|
|
|
|
|
|
|
use crate::Identifier;
|
|
|
|
|
|
|
|
pub fn all_built_in_identifiers() -> impl Iterator<Item = BuiltInIdentifier> {
|
|
|
|
all()
|
|
|
|
}
|
|
|
|
|
2024-02-15 21:30:47 +00:00
|
|
|
static OPTION: OnceLock<Identifier> = OnceLock::new();
|
|
|
|
static NONE: OnceLock<Identifier> = OnceLock::new();
|
2024-02-15 20:20:29 +00:00
|
|
|
|
2024-02-15 21:30:47 +00:00
|
|
|
#[derive(Sequence, Debug)]
|
2024-02-15 20:20:29 +00:00
|
|
|
pub enum BuiltInIdentifier {
|
|
|
|
Option,
|
|
|
|
None,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl BuiltInIdentifier {
|
2024-02-15 21:02:27 +00:00
|
|
|
pub fn get(&self) -> Identifier {
|
2024-02-15 20:20:29 +00:00
|
|
|
match self {
|
2024-02-15 21:30:47 +00:00
|
|
|
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(),
|
2024-02-15 20:20:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|