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 FrozenValues. See the type OwnedFrozenValue for a little bit more safety.

Implementations§

source§

impl FrozenValue

source

pub fn new_none() -> Self

Create a new value representing None in Starlark.

source

pub fn new_bool(x: bool) -> Self

Create a new boolean in Starlark.

source

pub fn is_none(self) -> bool

Is a value a Starlark None.

source

pub fn unpack_bool(self) -> Option<bool>

Return the bool if the value is a boolean, otherwise None.

source

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.

source

pub fn to_value<'v>(self) -> Value<'v>

Convert a FrozenValue back to a Value.

source

pub fn downcast_frozen_ref<T: StarlarkValue<'static>>( self ) -> Option<FrozenRef<'static, T>>

Downcast to given type.

source

pub fn downcast_frozen_str(self) -> Option<FrozenRef<'static, str>>

Downcast to string.

source

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

source§

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

source§

fn alloc_value(self, _heap: &'v Heap) -> Value<'v>

Allocate the value on a heap and return a reference to the allocated value. Read more
source§

impl Allocative for FrozenValue

source§

fn visit<'allocative_a, 'allocative_b: 'allocative_a>( &self, visitor: &'allocative_a mut Visitor<'allocative_b> )

source§

impl Clone for FrozenValue

source§

fn clone(&self) -> FrozenValue

Returns a copy 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 FrozenValue

source§

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

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

impl Default for FrozenValue

source§

fn default() -> Self

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

impl Display for FrozenValue

source§

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

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

impl Dupe for FrozenValue

source§

fn dupe(&self) -> Self

source§

impl Equivalent<FrozenValue> for Value<'_>

source§

fn equivalent(&self, key: &FrozenValue) -> bool

Compare self to key and return true if they are equal.
source§

impl Equivalent<Value<'_>> for FrozenValue

source§

fn equivalent(&self, key: &Value<'_>) -> bool

Compare self to key and return true if they are equal.
source§

impl Freeze for FrozenValue

§

type Frozen = FrozenValue

When type is frozen, it is frozen into this type.
source§

fn freeze(self, _freezer: &Freezer) -> Result<FrozenValue>

Freeze a value. The frozen value must be equal to the original, and produce the same hash. Read more
source§

impl PartialEq for FrozenValue

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'pst> ProvidesStaticType<'pst> for FrozenValue

§

type StaticType = FrozenValue

Same type as Self but with lifetimes dropped to 'static. Read more
source§

impl Serialize for FrozenValue

source§

fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl StarlarkTypeRepr for FrozenValue

source§

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

source§

fn trace(&mut self, _tracer: &Tracer<'v>)

Recursively “trace” the value. Read more
source§

impl<'v> ValueLike<'v> for FrozenValue

§

type String = FrozenValueTyped<'static, StarlarkStr>

StringValue or FrozenStringValue.
source§

fn to_value(self) -> Value<'v>

Produce a Value regardless of the type you are starting with.
source§

fn from_frozen_value(v: FrozenValue) -> Self

Convert from FrozenValue.
source§

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)

repr(x).
source§

fn write_hash(self, hasher: &mut StarlarkHasher) -> Result<()>

Hash the value.
source§

fn equals(self, other: Value<'v>) -> Result<bool>

x == other. Read more
source§

fn compare(self, other: Value<'v>) -> Result<Ordering>

x <=> other.
source§

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>>

Get hash value.
source§

fn collect_str(self, collector: &mut String)

str(x).
source§

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.
source§

impl<'v> Coerce<Value<'v>> for FrozenValue

source§

impl<'v> CoerceKey<Value<'v>> for FrozenValue

source§

impl Copy for FrozenValue

source§

impl Eq for FrozenValue

source§

impl Send for FrozenValue

source§

impl Sync for FrozenValue

Auto Trait Implementations§

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<'a, T> AnyLifetime<'a> for T
where T: ProvidesStaticType<'a> + 'a + ?Sized,

source§

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

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> 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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> Serialize for T
where T: Serialize + ?Sized,

source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>

source§

impl<T> ToAst for T

source§

fn ast(self, begin: usize, end: usize) -> Spanned<Self>

source§

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

§

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§

default 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>,

§

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>,

§

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.