#[cfg(doc)]
pub mod reference;
pub mod ast;
mod checker;
mod execution;
pub mod functions;
pub mod graph;
pub mod parse_error;
mod parser;
mod variables;
pub use execution::error::ExecutionError;
pub use execution::CancellationError;
pub use execution::CancellationFlag;
pub use execution::ExecutionConfig;
pub use execution::Match;
pub use execution::NoCancellation;
pub use parser::Location;
pub use parser::ParseError;
pub use variables::Globals as Variables;
pub use variables::Iter as VariableIter;
pub use variables::VariableError;
use std::borrow::Borrow;
use std::hash::Hash;
use std::ops::Deref;
use std::sync::Arc;
use serde::Serialize;
use serde::Serializer;
#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub struct Identifier(Arc<String>);
impl Identifier {
pub fn as_str(&self) -> &str {
self.0.as_str()
}
pub fn into_string(mut self) -> String {
Arc::make_mut(&mut self.0);
Arc::try_unwrap(self.0).unwrap()
}
}
impl Borrow<str> for Identifier {
fn borrow(&self) -> &str {
self.as_str()
}
}
impl Deref for Identifier {
type Target = str;
fn deref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for Identifier {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.0.fmt(f)
}
}
impl From<&str> for Identifier {
fn from(value: &str) -> Identifier {
Identifier(Arc::new(String::from(value)))
}
}
impl Hash for Identifier {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.0.hash(state);
}
}
impl PartialEq<str> for Identifier {
fn eq(&self, other: &str) -> bool {
self.as_str() == other
}
}
impl<'a> PartialEq<&'a str> for Identifier {
fn eq(&self, other: &&'a str) -> bool {
self.as_str() == *other
}
}
impl Serialize for Identifier {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
serializer.serialize_str(self.as_str())
}
}