30 lines
685 B
Rust
30 lines
685 B
Rust
|
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 {
|
||
|
pub fn get(&self) -> &Identifier {
|
||
|
match self {
|
||
|
BuiltInIdentifier::Option => {
|
||
|
return OPTION.get_or_init(|| Identifier::new("Option"));
|
||
|
}
|
||
|
BuiltInIdentifier::None => return NONE.get_or_init(|| Identifier::new("None")),
|
||
|
}
|
||
|
}
|
||
|
}
|