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: ValueKind
Underlying 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 Value
s 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 Literal
s 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.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Value
impl<'de> Deserialize<'de> for Value
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<T: Into<Literal>> From<T> for Value
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
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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