pub trait ValueLike<'v>: Eq + Copy + Debug + Default + Display + Serialize + CoerceKey<Value<'v>> + Freeze<Frozen = FrozenValue> + Allocative + ProvidesStaticType<'v> + Sealed + 'v {
type String: StringValueLike<'v>;
// Required methods
fn to_value(self) -> Value<'v>;
fn from_frozen_value(v: FrozenValue) -> Self;
fn write_hash(self, hasher: &mut StarlarkHasher) -> Result<()>;
fn collect_repr(self, collector: &mut String);
fn equals(self, other: Value<'v>) -> Result<bool>;
fn compare(self, other: Value<'v>) -> Result<Ordering>;
fn downcast_ref<T: StarlarkValue<'v>>(self) -> Option<&'v T>;
// Provided methods
fn invoke(
self,
args: &Arguments<'v, '_>,
eval: &mut Evaluator<'v, '_>
) -> Result<Value<'v>> { ... }
fn get_hashed(self) -> Result<Hashed<Self>> { ... }
fn collect_str(self, collector: &mut String) { ... }
fn downcast_ref_err<T: StarlarkValue<'v>>(self) -> Result<&'v T> { ... }
}
Expand description
Abstract over Value
and FrozenValue
.
The methods on this trait are those required to implement containers,
allowing implementations of ComplexValue
to be agnostic of their contained type.
For details about each function, see the documentation for Value
,
which provides the same functions (and more).
Required Associated Types§
sourcetype String: StringValueLike<'v>
type String: StringValueLike<'v>
StringValue
or FrozenStringValue
.
Required Methods§
sourcefn from_frozen_value(v: FrozenValue) -> Self
fn from_frozen_value(v: FrozenValue) -> Self
Convert from FrozenValue
.
sourcefn write_hash(self, hasher: &mut StarlarkHasher) -> Result<()>
fn write_hash(self, hasher: &mut StarlarkHasher) -> Result<()>
Hash the value.
sourcefn collect_repr(self, collector: &mut String)
fn collect_repr(self, collector: &mut String)
repr(x)
.
sourcefn equals(self, other: Value<'v>) -> Result<bool>
fn equals(self, other: Value<'v>) -> Result<bool>
x == other
.
This operation can only return error on stack overflow.
sourcefn 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.
Provided Methods§
sourcefn 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.
sourcefn get_hashed(self) -> Result<Hashed<Self>>
fn get_hashed(self) -> Result<Hashed<Self>>
Get hash value.
sourcefn collect_str(self, collector: &mut String)
fn collect_str(self, collector: &mut String)
str(x)
.
sourcefn 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.
Object Safety§
This trait is not object safe.