pub enum Value {
Null,
Bool(bool),
Integer(i64),
Float(f64),
Text(Rc<str>),
List(Rc<[Value]>),
Map(Rc<IndexMap<Rc<str>, Value>>),
PatternMatches(Rc<str>, Vec<Rc<PatternMatch>>),
NativePatternMatch(Rc<NativePatternMatch>),
Type(Type),
}Expand description
A Ryan value.
Variants§
Null
The value null.
Bool(bool)
A boolean.
Integer(i64)
An integer.
Float(f64)
A floating point, including scarry stuff like inf and NaN.
Text(Rc<str>)
An utf-8 encoded string.
List(Rc<[Value]>)
A list of other Ryan values.
Map(Rc<IndexMap<Rc<str>, Value>>)
An association of strings to other Ryan values.
PatternMatches(Rc<str>, Vec<Rc<PatternMatch>>)
A list of pattern match rules for a given identifier.
NativePatternMatch(Rc<NativePatternMatch>)
A pattern match where the code to be executed in case of a match is native code, not a Ryan block.
Type(Type)
A Ryan type.
Implementations§
Source§impl Value
impl Value
Sourcepub fn is_true(&self) -> Result<bool, String>
pub fn is_true(&self) -> Result<bool, String>
Tests the “truthiness” of a value. Currently, only true is true; values other
than a boolean will raise an error.
Sourcepub fn matches(&self, lit: &Literal) -> bool
pub fn matches(&self, lit: &Literal) -> bool
“Equality” between a value and a Literal. Literals are nodes in the abstract
syntax tree, while values are not.
Sourcepub fn iter(&self) -> Result<ValueIter<'_>, NotIterable>
pub fn iter(&self) -> Result<ValueIter<'_>, NotIterable>
Tries to return an iterator, if the value is iterable
Sourcepub fn extract_path(&self, path: &[Value]) -> Result<Value, String>
pub fn extract_path(&self, path: &[Value]) -> Result<Value, String>
Extracts the value lying at the end of a path in a nested Ryan value.
pub fn canonical_type(&self) -> Type
pub fn decode<T>(&self) -> Result<T, DecodeError>where
T: for<'a> Deserialize<'a>,
Trait Implementations§
Source§impl FromIterator<Value> for Value
impl FromIterator<Value> for Value
Source§impl PartialOrd for Value
impl PartialOrd for Value
impl StructuralPartialEq for Value
Auto Trait Implementations§
impl Freeze for Value
impl !RefUnwindSafe for Value
impl !Send for Value
impl !Sync for Value
impl Unpin for Value
impl !UnwindSafe for Value
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more