Struct starlark::values::FrozenValue
source · pub struct FrozenValue(/* private fields */);
Expand description
A Value
that can never be changed. Can be converted back to a Value
with to_value
.
A FrozenValue
exists on a FrozenHeap
, which in turn can be kept
alive by a FrozenHeapRef
. If the frozen heap gets dropped
while a FrozenValue
from it still exists, the program will probably segfault, so be careful
when working directly with FrozenValue
s. See the type OwnedFrozenValue
for a little bit more safety.
Implementations§
source§impl FrozenValue
impl FrozenValue
sourcepub fn unpack_bool(self) -> Option<bool>
pub fn unpack_bool(self) -> Option<bool>
sourcepub fn unpack_i32(self) -> Option<i32>
pub fn unpack_i32(self) -> Option<i32>
Obtain the underlying integer if it fits in an i32
.
Note floats are not considered integers, i. e. unpack_i32
for 1.0
will return None
.
sourcepub fn to_value<'v>(self) -> Value<'v>
pub fn to_value<'v>(self) -> Value<'v>
Convert a FrozenValue
back to a Value
.
sourcepub fn downcast_frozen_ref<T: StarlarkValue<'static>>(
self
) -> Option<FrozenRef<'static, T>>
pub fn downcast_frozen_ref<T: StarlarkValue<'static>>( self ) -> Option<FrozenRef<'static, T>>
Downcast to given type.
sourcepub fn downcast_frozen_str(self) -> Option<FrozenRef<'static, str>>
pub fn downcast_frozen_str(self) -> Option<FrozenRef<'static, str>>
Downcast to string.
sourcepub fn downcast_frozen_starlark_str(
self
) -> Option<FrozenRef<'static, StarlarkStr>>
pub fn downcast_frozen_starlark_str( self ) -> Option<FrozenRef<'static, StarlarkStr>>
Note: see docs about [‘Value::unpack_box_str’] about instability
Trait Implementations§
source§impl AllocFrozenValue for FrozenValue
impl AllocFrozenValue for FrozenValue
source§fn alloc_frozen_value(self, _heap: &FrozenHeap) -> FrozenValue
fn alloc_frozen_value(self, _heap: &FrozenHeap) -> FrozenValue
Allocate a value in the frozen heap and return a reference to the allocated value.
source§impl<'v> AllocValue<'v> for FrozenValue
impl<'v> AllocValue<'v> for FrozenValue
source§impl Allocative for FrozenValue
impl Allocative for FrozenValue
source§impl Clone for FrozenValue
impl Clone for FrozenValue
source§fn clone(&self) -> FrozenValue
fn clone(&self) -> FrozenValue
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for FrozenValue
impl Debug for FrozenValue
source§impl Default for FrozenValue
impl Default for FrozenValue
source§impl Display for FrozenValue
impl Display for FrozenValue
source§impl Equivalent<FrozenValue> for Value<'_>
impl Equivalent<FrozenValue> for Value<'_>
source§fn equivalent(&self, key: &FrozenValue) -> bool
fn equivalent(&self, key: &FrozenValue) -> bool
Compare self to
key
and return true
if they are equal.source§impl Equivalent<Value<'_>> for FrozenValue
impl Equivalent<Value<'_>> for FrozenValue
source§fn equivalent(&self, key: &Value<'_>) -> bool
fn equivalent(&self, key: &Value<'_>) -> bool
Compare self to
key
and return true
if they are equal.source§impl Freeze for FrozenValue
impl Freeze for FrozenValue
§type Frozen = FrozenValue
type Frozen = FrozenValue
When type is frozen, it is frozen into this type.
source§impl PartialEq for FrozenValue
impl PartialEq for FrozenValue
source§fn eq(&self, other: &FrozenValue) -> bool
fn eq(&self, other: &FrozenValue) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl<'pst> ProvidesStaticType<'pst> for FrozenValue
impl<'pst> ProvidesStaticType<'pst> for FrozenValue
§type StaticType = FrozenValue
type StaticType = FrozenValue
source§impl Serialize for FrozenValue
impl Serialize for FrozenValue
source§impl StarlarkTypeRepr for FrozenValue
impl StarlarkTypeRepr for FrozenValue
source§fn starlark_type_repr() -> Ty
fn starlark_type_repr() -> Ty
The representation of a type that a user would use verbatim in starlark type annotations
source§impl<'v> Trace<'v> for FrozenValue
impl<'v> Trace<'v> for FrozenValue
source§impl<'v> ValueLike<'v> for FrozenValue
impl<'v> ValueLike<'v> for FrozenValue
§type String = FrozenValueTyped<'static, StarlarkStr>
type String = FrozenValueTyped<'static, StarlarkStr>
StringValue
or FrozenStringValue
.source§fn from_frozen_value(v: FrozenValue) -> Self
fn from_frozen_value(v: FrozenValue) -> Self
Convert from
FrozenValue
.source§fn downcast_ref<T: StarlarkValue<'v>>(self) -> Option<&'v T>
fn downcast_ref<T: StarlarkValue<'v>>(self) -> Option<&'v T>
Get a reference to underlying data or
None
if contained object has different type than requested.source§fn collect_repr(self, collector: &mut String)
fn collect_repr(self, collector: &mut String)
repr(x)
.source§fn write_hash(self, hasher: &mut StarlarkHasher) -> Result<()>
fn write_hash(self, hasher: &mut StarlarkHasher) -> Result<()>
Hash the value.
source§fn invoke(
self,
args: &Arguments<'v, '_>,
eval: &mut Evaluator<'v, '_>
) -> Result<Value<'v>>
fn invoke( self, args: &Arguments<'v, '_>, eval: &mut Evaluator<'v, '_> ) -> Result<Value<'v>>
Call this value as a function with given arguments.
source§fn get_hashed(self) -> Result<Hashed<Self>>
fn get_hashed(self) -> Result<Hashed<Self>>
Get hash value.
source§fn collect_str(self, collector: &mut String)
fn collect_str(self, collector: &mut String)
str(x)
.source§fn downcast_ref_err<T: StarlarkValue<'v>>(self) -> Result<&'v T>
fn downcast_ref_err<T: StarlarkValue<'v>>(self) -> Result<&'v T>
Get a reference to underlying data or
Err
if contained object has different type than requested.impl<'v> Coerce<Value<'v>> for FrozenValue
impl<'v> CoerceKey<Value<'v>> for FrozenValue
impl Copy for FrozenValue
impl Eq for FrozenValue
impl Send for FrozenValue
impl Sync for FrozenValue
Auto Trait Implementations§
Blanket Implementations§
source§impl<'a, T> AnyLifetime<'a> for Twhere
T: ProvidesStaticType<'a> + 'a + ?Sized,
impl<'a, T> AnyLifetime<'a> for Twhere
T: ProvidesStaticType<'a> + 'a + ?Sized,
source§fn static_type_id() -> TypeId
fn static_type_id() -> TypeId
Must return the
TypeId
of Self
but where the lifetimes are changed
to 'static
. Must be consistent with static_type_of
.source§fn static_type_of(&self) -> TypeId
fn static_type_of(&self) -> TypeId
Must return the
TypeId
of Self
but where the lifetimes are changed
to 'static
. Must be consistent with static_type_id
. Must not
consult the self
parameter in any way.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
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.