Struct starlark::values::ValueTyped

source ·
pub struct ValueTyped<'v, T: StarlarkValue<'v>>(/* private fields */);
Expand description

Value wrapper which asserts contained value is of type <T>.

Implementations§

source§

impl<'v> ValueTyped<'v, StarlarkStr>

source

pub fn freeze(self, freezer: &Freezer) -> Result<FrozenStringValue>

Convert a value to a FrozenStringValue using a supplied Freezer.

source

pub fn get_hashed(self) -> Hashed<Self>

Get self along with the hash.

source

pub fn get_hashed_str(self) -> Hashed<&'v str>

Get the string reference along with the hash.

source

pub fn get_hashed_value(self) -> Hashed<Value<'v>>

Get the Value along with the hash.

source

pub fn unpack_frozen(self) -> Option<FrozenStringValue>

If this string value is frozen, return it.

source§

impl<'v, T: StarlarkValue<'v>> ValueTyped<'v, T>

source

pub fn new(value: Value<'v>) -> Option<ValueTyped<'v, T>>

Downcast.

source

pub fn new_err(value: Value<'v>) -> Result<ValueTyped<'v, T>>

Downcast.

source

pub unsafe fn new_unchecked(value: Value<'v>) -> ValueTyped<'v, T>

Construct typed value without checking the value is of type <T>.

source

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

Erase the type.

source

pub fn as_ref(self) -> &'v T

Get the reference to the pointed value.

source

pub fn hashed(self) -> Result<Hashed<Self>>

Compute the hash value.

source§

impl<'v> ValueTyped<'v, StarlarkStr>

source

pub fn as_str(self) -> &'v str

Get the Rust string reference.

Trait Implementations§

source§

impl<'v, T: StarlarkValue<'v>> AllocValue<'v> for ValueTyped<'v, T>

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<'v, T: StarlarkValue<'v>> Allocative for ValueTyped<'v, T>

source§

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

source§

impl<'v, T: StarlarkValue<'v>> Clone for ValueTyped<'v, T>

source§

fn clone(&self) -> Self

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<'v, T: StarlarkValue<'v>> Debug for ValueTyped<'v, T>

source§

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

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

impl<'v, T: StarlarkValue<'v>> Deref for ValueTyped<'v, T>

§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &T

Dereferences the value.
source§

impl<'v, T: StarlarkValue<'v>> Display for ValueTyped<'v, T>

source§

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

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

impl<'v, T: StarlarkValue<'v>> Dupe for ValueTyped<'v, T>

source§

fn dupe(&self) -> Self

source§

impl<'v> Equivalent<ValueTyped<'v, StarlarkStr>> for FrozenStringValue

source§

fn equivalent(&self, key: &StringValue<'v>) -> bool

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

impl<'v, T> From<ValueTyped<'v, T>> for ValueTypedComplex<'v, T>
where T: ComplexValue<'v>, T::Frozen: StarlarkValue<'static>,

source§

fn from(t: ValueTyped<'v, T>) -> Self

Converts to this type from the input type.
source§

impl<'v> PartialEq<ValueTyped<'v, StarlarkStr>> for FrozenStringValue

source§

fn eq(&self, other: &StringValue<'v>) -> 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<'v, T: StarlarkValue<'v>> PartialEq for ValueTyped<'v, T>

source§

fn eq(&self, other: &Self) -> 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<'v, T: StarlarkValue<'v> + ProvidesStaticType<'v> + Sized> ProvidesStaticType<'v> for ValueTyped<'v, T>
where T::StaticType: StarlarkValue<'static> + Sized,

§

type StaticType = ValueTyped<'static, <T as ProvidesStaticType<'v>>::StaticType>

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

impl<'v, T: StarlarkValue<'v>> Serialize for ValueTyped<'v, T>

source§

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

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

impl<'v, T: StarlarkValue<'v>> StarlarkTypeRepr for ValueTyped<'v, T>

source§

fn starlark_type_repr() -> Ty

The representation of a type that a user would use verbatim in starlark type annotations
source§

impl<'v, T: StarlarkValue<'v>> Trace<'v> for ValueTyped<'v, T>

source§

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

Recursively “trace” the value. Read more
source§

impl<'v, T: StarlarkValue<'v>> UnpackValue<'v> for ValueTyped<'v, T>

source§

fn expected() -> String

Description of values acceptable by unpack_value, e. g. list or str.
source§

fn unpack_value(value: Value<'v>) -> Option<Self>

Given a Value, try and unpack it into the given type, which may involve some element of conversion.
source§

fn unpack_value_err(value: Value<'v>) -> Result<Self>

Unpack a value, but return error instead of None if unpacking fails.
source§

fn unpack_param(value: Value<'v>) -> Result<Self>

Unpack value, but instead of None return error about incorrect argument type.
source§

fn unpack_named_param(value: Value<'v>, param_name: &str) -> Result<Self>

Unpack value, but instead of None return error about incorrect named argument type.
source§

impl<'v, T: StarlarkValue<'v>> Coerce<Value<'v>> for ValueTyped<'v, T>

source§

impl<'v> Coerce<ValueTyped<'v, StarlarkStr>> for FrozenStringValue

source§

impl<'v, T: StarlarkValue<'v>> Coerce<ValueTyped<'v, T>> for ValueTyped<'v, T>

source§

impl<'v, T: StarlarkValue<'v>> CoerceKey<Value<'v>> for ValueTyped<'v, T>

source§

impl<'v> CoerceKey<ValueTyped<'v, StarlarkStr>> for FrozenStringValue

source§

impl<'v, T: StarlarkValue<'v>> CoerceKey<ValueTyped<'v, T>> for ValueTyped<'v, T>

source§

impl<'v, T: StarlarkValue<'v>> Copy for ValueTyped<'v, T>

source§

impl<'v, T: StarlarkValue<'v>> Eq for ValueTyped<'v, T>

Auto Trait Implementations§

§

impl<'v, T> !RefUnwindSafe for ValueTyped<'v, T>

§

impl<'v, T> Send for ValueTyped<'v, T>
where T: Sync,

§

impl<'v, T> !Sync for ValueTyped<'v, T>

§

impl<'v, T> Unpin for ValueTyped<'v, T>

§

impl<'v, T> UnwindSafe for ValueTyped<'v, T>
where T: RefUnwindSafe,

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
§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
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.