Enum Expr

Source
pub enum Expr {
Show 33 variants Never, None, Comment(String, CommentKind), TextSeparator, Annotation(String), Bool(bool), U8(u8), Int(i64), Float(f64), Dec(Decimal), Symbol(String), KeySymbol(String), Char(char), String(String), Type(String), List(Vec<Expr>), Array(Arc<RwLock<Vec<Expr>>>), Buffer(usize, Arc<RwLock<Vec<u8>>>), Map(Arc<RwLock<HashMap<String, Expr>>>), Set(Arc<RwLock<HashSet<Expr>>>), IntRange(i64, i64, i64), FloatRange(f64, f64, f64), Func(Vec<Expr>, Vec<Expr>, Arc<Scope>, String), Macro(Vec<Expr>, Vec<Expr>), ForeignFunc(ForeignFnRef), Foreign(Arc<dyn Any + Send + Sync>), ForeignMut(Arc<RwLock<dyn Any + Send + Sync>>), Error(String), Do, Let, If(Box<Expr>, Box<Expr>, Option<Box<Expr>>), Annotated(Box<Expr>, HashMap<String, Expr>), Module(Arc<Module>),
}
Expand description

A symbolic expression. This is the ‘universal’ data type in the language, all values are expressions (and expressions are values). Evaluation is expression rewriting to a fixed point.

Variants§

§

Never

§

None

§

Comment(String, CommentKind)

§

TextSeparator

§

Annotation(String)

§

Bool(bool)

§

U8(u8)

§

Int(i64)

§

Float(f64)

§

Dec(Decimal)

§

Symbol(String)

§

KeySymbol(String)

§

Char(char)

§

String(String)

§

Type(String)

§

List(Vec<Expr>)

§

Array(Arc<RwLock<Vec<Expr>>>)

§

Buffer(usize, Arc<RwLock<Vec<u8>>>)

§

Map(Arc<RwLock<HashMap<String, Expr>>>)

§

Set(Arc<RwLock<HashSet<Expr>>>)

§

IntRange(i64, i64, i64)

§

FloatRange(f64, f64, f64)

§

Func(Vec<Expr>, Vec<Expr>, Arc<Scope>, String)

Func(params, body, func_scope, filename)

§

Macro(Vec<Expr>, Vec<Expr>)

Macro(params, body)

§

ForeignFunc(ForeignFnRef)

§

Foreign(Arc<dyn Any + Send + Sync>)

§

ForeignMut(Arc<RwLock<dyn Any + Send + Sync>>)

§

Error(String)

§

Do

§

Let

§

If(Box<Expr>, Box<Expr>, Option<Box<Expr>>)

§

Annotated(Box<Expr>, HashMap<String, Expr>)

§

Module(Arc<Module>)

Implementations§

Source§

impl Expr

Source

pub fn iter(&self) -> ExprIter<'_>

Source§

impl Expr

Source

pub fn transform<F>(self, f: &F) -> Self
where F: Fn(Self) -> Self,

Transforms the expression by recursively applying the f mapping function.

Source

pub fn try_transform<F>(self, f: &F) -> Result<Self, Error>
where F: Fn(Self) -> Result<Self, Error>,

Source

pub fn transform_mut<F>(self, f: &mut F) -> Self
where F: FnMut(Self) -> Self,

Source

pub fn transform_bfs<F>(self, _f: &F) -> Self
where F: Fn(Self) -> Self,

Transforms the expression by recursively applying the f mapping function, breadth-first-search

Source

pub fn quot(self, context: &mut Context) -> Self

Source

pub fn filter_transform<F>(self, f: &F) -> Option<Self>
where F: Fn(Self) -> Option<Self>,

Transforms the expression by recursively applying the f mapping function.

Source§

impl Expr

Source

pub fn symbol(s: impl Into<String>) -> Self

Source

pub fn key_symbol(s: impl Into<String>) -> Self

Source

pub fn string(s: impl Into<String>) -> Self

Source

pub fn error(s: impl Into<String>) -> Self

Source

pub fn typ(s: impl Into<String>) -> Self

Source

pub fn array(a: impl Into<Vec<Expr>>) -> Self

Source

pub fn map(m: impl Into<HashMap<String, Expr>>) -> Self

Source

pub fn set(s: impl Into<HashSet<Expr>>) -> Self

Source

pub fn foreign_func(f: &'static FnNoContext) -> Self

Source

pub fn foreign_func_mut_context(f: &'static FnMutContext) -> Self

Source

pub fn annotated(expr: Expr, annotations: &HashMap<String, Expr>) -> Self

Source

pub fn maybe_annotated( expr: Expr, annotations: Option<&HashMap<String, Expr>>, ) -> Self

Source§

impl Expr

Source

pub fn annotations(&self) -> Option<&HashMap<String, Expr>>

Source

pub fn annotations_mut(&mut self) -> Option<&mut HashMap<String, Expr>>

Source

pub fn extract(&self) -> (&Expr, Option<&HashMap<String, Expr>>)

Source

pub fn unpack(&self) -> &Self

Removes the annotation from an expression.

Source

pub fn unpack_consuming(self) -> Self

Source

pub fn annotation(&self, name: impl Into<String>) -> Option<&Expr>

Source

pub fn is_none(&self) -> bool

Source

pub fn is_func(&self) -> bool

Source

pub fn is_invocable(&self) -> bool

Source

pub fn is_transient(&self) -> bool

Source

pub fn is_false(&self) -> bool

Source

pub fn as_int(&self) -> Option<i64>

Source

pub fn as_u8(&self) -> Option<u8>

Source

pub fn as_float(&self) -> Option<f64>

Source

pub fn as_float_range(&self) -> Option<Range<f64>>

Source

pub fn as_decimal(&self) -> Option<Decimal>

Source

pub fn as_bool(&self) -> Option<bool>

Source

pub fn as_string(&self) -> Option<&str>

Source

pub fn as_stringable(&self) -> Option<&str>

Source

pub fn as_stringable_consuming(self) -> Option<String>

Source

pub fn is_symbol(&self) -> bool

Source

pub fn as_symbol(&self) -> Option<&str>

Source

pub fn as_key_symbol(&self) -> Option<&str>

Source

pub fn as_symbolic(&self) -> Option<&str>

Tries to extract Symbol or KeySymbol.

Source

pub fn as_type(&self) -> Option<&str>

Source

pub fn as_char(&self) -> Option<char>

Source

pub fn as_list(&self) -> Option<&Vec<Expr>>

Source

pub fn as_array(&self) -> Option<RwLockReadGuard<'_, Vec<Expr>>>

Source

pub fn as_array_consuming(self) -> Option<Arc<RwLock<Vec<Expr>>>>

Source

pub fn as_array_mut(&self) -> Option<RwLockWriteGuard<'_, Vec<Expr>>>

Source

pub fn as_buffer(&self) -> Option<RwLockReadGuard<'_, Vec<u8>>>

Source

pub fn as_buffer_mut(&self) -> Option<(usize, RwLockWriteGuard<'_, Vec<u8>>)>

Source

pub fn as_map(&self) -> Option<RwLockReadGuard<'_, HashMap<String, Expr>>>

Source

pub fn as_map_mut(&self) -> Option<RwLockWriteGuard<'_, HashMap<String, Expr>>>

Source

pub fn as_set(&self) -> Option<RwLockReadGuard<'_, HashSet<Expr>>>

Source

pub fn as_set_mut(&self) -> Option<RwLockWriteGuard<'_, HashSet<Expr>>>

Source

pub fn static_type(&self) -> &Expr

Source

pub fn dyn_type(&self, context: &Context) -> Expr

Source

pub fn range(&self) -> Option<Range>

Trait Implementations§

Source§

impl AsRef<Expr> for Expr

Source§

fn as_ref(&self) -> &Expr

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Expr

Source§

fn clone(&self) -> Expr

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Expr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Expr

Source§

fn default() -> Expr

Returns the “default value” for a type. Read more
Source§

impl Display for Expr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<f64> for Expr

Source§

fn from(item: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for Expr

Source§

fn from(item: i64) -> Self

Converts to this type from the input type.
Source§

impl Hash for Expr

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Expr

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Expr

Auto Trait Implementations§

§

impl Freeze for Expr

§

impl !RefUnwindSafe for Expr

§

impl Send for Expr

§

impl Sync for Expr

§

impl Unpin for Expr

§

impl !UnwindSafe for Expr

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.