2024-02-15 20:20:29 +00:00
|
|
|
use std::sync::OnceLock;
|
|
|
|
|
|
|
|
use enum_iterator::{all, Sequence};
|
|
|
|
|
|
|
|
use crate::Identifier;
|
|
|
|
|
|
|
|
pub fn all_built_in_identifiers() -> impl Iterator<Item = BuiltInIdentifier> {
|
|
|
|
all()
|
|
|
|
}
|
|
|
|
|
|
|
|
const OPTION: OnceLock<Identifier> = OnceLock::new();
|
|
|
|
const NONE: OnceLock<Identifier> = OnceLock::new();
|
|
|
|
|
|
|
|
#[derive(Sequence)]
|
|
|
|
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:02:27 +00:00
|
|
|
BuiltInIdentifier::Option => OPTION.get_or_init(|| Identifier::new("Option")).clone(),
|
|
|
|
BuiltInIdentifier::None => NONE.get_or_init(|| Identifier::new("None")).clone(),
|
2024-02-15 20:20:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|