pub struct Value {
pub value: ValueKind,
pub loc: Option<Loc>,
}Expand description
This describes all the values which could be the dynamic result of evaluating an Expr.
Cloning is O(1).
Fields§
§value: ValueKindUnderlying actual value
loc: Option<Loc>Source location associated with the value, if any
Implementations§
Source§impl Value
impl Value
Sourcepub fn empty_record(loc: Option<Loc>) -> Self
pub fn empty_record(loc: Option<Loc>) -> Self
Create a new empty record
Sourcepub fn new(value: impl Into<ValueKind>, loc: Option<Loc>) -> Self
pub fn new(value: impl Into<ValueKind>, loc: Option<Loc>) -> Self
Create a Value from anything that implements Into<ValueKind> and an
optional source location
Sourcepub fn set(vals: impl IntoIterator<Item = Value>, loc: Option<Loc>) -> Self
pub fn set(vals: impl IntoIterator<Item = Value>, loc: Option<Loc>) -> Self
Create a set with the given Values as elements
Sourcepub fn set_of_lits(
lits: impl IntoIterator<Item = Literal>,
loc: Option<Loc>,
) -> Self
pub fn set_of_lits( lits: impl IntoIterator<Item = Literal>, loc: Option<Loc>, ) -> Self
Create a set with the given Literals as elements
the resulting Value will have the given loc attached, but its
individual Literal elements will not have a source loc attached
Sourcepub fn record<K: Into<SmolStr>, V: Into<Value>>(
pairs: impl IntoIterator<Item = (K, V)>,
loc: Option<Loc>,
) -> Self
pub fn record<K: Into<SmolStr>, V: Into<Value>>( pairs: impl IntoIterator<Item = (K, V)>, loc: Option<Loc>, ) -> Self
Create a record with the given (key, value) pairs
Sourcepub fn record_arc(
pairs: Arc<BTreeMap<SmolStr, Value>>,
loc: Option<Loc>,
) -> Self
pub fn record_arc( pairs: Arc<BTreeMap<SmolStr, Value>>, loc: Option<Loc>, ) -> Self
Create a record with the given attributes/value mapping.
Sourcepub fn with_maybe_source_loc(self, loc: Option<Loc>) -> Self
pub fn with_maybe_source_loc(self, loc: Option<Loc>) -> Self
Return the Value, but with the given Loc (or None)
Sourcepub fn value_kind(&self) -> &ValueKind
pub fn value_kind(&self) -> &ValueKind
Get the ValueKind for this Value
Sourcepub fn source_loc(&self) -> Option<&Loc>
pub fn source_loc(&self) -> Option<&Loc>
Get the Loc attached to this Value, if there is one
Sourcepub fn eq_and_same_source_loc(&self, other: &Self) -> bool
pub fn eq_and_same_source_loc(&self, other: &Self) -> bool
The PartialEq and Eq implementations for Value ignore the source location.
If you actually want to check that two values are equal and have the
same source location, you can use this.
Sourcepub fn all_literal_uids(&self) -> HashSet<EntityUID>
pub fn all_literal_uids(&self) -> HashSet<EntityUID>
All literal uids referenced by this value
Trait Implementations§
Source§impl BoundedDisplay for Value
impl BoundedDisplay for Value
Source§impl<T: Into<Literal>> From<T> for Value
Create a Value directly from a Literal, or from anything that implements
Into<Literal> (so Integer, &str, EntityUID, etc)
impl<T: Into<Literal>> From<T> for Value
Create a Value directly from a Literal, or from anything that implements
Into<Literal> (so Integer, &str, EntityUID, etc)
This impl does not propagate source location; the resulting Value will
have no source location info attached
Source§impl From<Value> for RestrictedExpr
impl From<Value> for RestrictedExpr
Source§fn from(value: Value) -> RestrictedExpr
fn from(value: Value) -> RestrictedExpr
Source§impl<T: Into<Value>> From<Vec<T>> for Value
Create a Value directly from a Vec<Value>, or Vec<T> where T: Into<Value>
(so Vec<Integer>, Vec<String>, etc)
impl<T: Into<Value>> From<Vec<T>> for Value
Create a Value directly from a Vec<Value>, or Vec<T> where T: Into<Value>
(so Vec<Integer>, Vec<String>, etc)
This impl does not propagate source location; the resulting Value will
have no source location info attached
Source§impl FromIterator<Value> for Set
impl FromIterator<Value> for Set
Source§impl Ord for Value
impl Ord for Value
Source§impl PartialOrd for Value
impl PartialOrd for Value
Source§impl TryFrom<PartialValue> for Value
impl TryFrom<PartialValue> for Value
Source§type Error = PartialValueToValueError
type Error = PartialValueToValueError
impl Eq 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
Source§impl<T> BoundedToString for Twhere
T: BoundedDisplay,
impl<T> BoundedToString for Twhere
T: BoundedDisplay,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more