Struct starlark::values::Value [−][src]
pub struct Value<'v>(_);
Expand description
A Starlark value. The lifetime argument 'v
corresponds to the Heap
it is stored on.
Many of the methods simply forward to the underlying StarlarkValue
.
Implementations
Turn a FrozenValue
into a Value
. See the safety warnings on
OwnedFrozenValue
.
Obtain the underlying FrozenValue
from inside the Value
, if it is one.
Obtain the underlying bool
if it is a boolean.
Obtain the underlying int
if it is an integer.
Like unpack_str
, but gives a pointer to a boxed string.
Mostly useful for when you want to convert the string to a dyn
trait, but can’t
form a dyn
of an unsized type.
Unstable and likely to be removed in future, as the presence of the Box
is
not a guaranteed part of the API.
Obtain the underlying str
if it is a string.
Are two Value
s equal, looking at only their underlying pointer. This function is
low-level and provides two guarantees.
- It is reflexive, the same
Value
passed as both arguments will result intrue
. - If this function is
true
, thenValue::equals
will also consider them equal.
Note that other properties are not guaranteed, and the result is not considered part of the API. The result can be impacted by optimisations such as hash-consing, copy-on-write, partial evaluation etc.
Convert a value to a FrozenValue
using a supplied Freezer
.
Implement the str()
function - converts a string value to itself,
otherwise uses repr()
.
Forwards to StarlarkValue::set_attr
.
Forwards to StarlarkValue::set_at
.
Return the contents of an iterable collection, as an owned vector.
Operate over an iterable for a value.
Produce an iterable from a value.
Are two values equal. If the values are of different types it will
return false
. It will only error if there is excessive recursion.
How are two values comparable. For values of different types will return Err
.
Describe the value, in order to get its metadata in a way that could be used
to generate prototypes, help information or whatever other descriptive text
is required.
Plan is to make this return a data type at some point in the future, possibly
move on to StarlarkValue
and include data from members.
Call export_as
on the underlying value, but only if the type is mutable.
Otherwise, does nothing.
Return the attribute with the given name. Returns a pair of a boolean and the value.
The type is AttrType::Method
if the attribute was defined via StarlarkValue::get_methods
and should be used as a signal that if the attribute is subsequently called,
e.g. object.attribute(argument)
then the object
should be passed as the first
argument to the function, e.g. object.attribute(object, argument)
.
Like get_attr
but return an error if the attribute is not available.
Query whether an attribute exists on a type. Should be equivalent to whether
get_attr
succeeds, but potentially more efficient.
Methods that just forward to the underlying StarlarkValue
.
pub fn slice(
self,
start: Option<Value<'v>>,
stop: Option<Value<'v>>,
stride: Option<Value<'v>>,
heap: &'v Heap
) -> Result<Value<'v>>
pub fn invoke(
self,
location: Option<Span>,
args: Arguments<'v, '_>,
eval: &mut Evaluator<'v, '_>
) -> Result<Value<'v>>
Invoke a function with only positional arguments.
Trait Implementations
Compare self to key
and return true
if they are equal.
Compare self to key
and return true
if they are equal.
Compare self to key
and return true
if they are equal.
Auto Trait Implementations
impl<'v> !RefUnwindSafe for Value<'v>
impl<'v> !UnwindSafe for Value<'v>
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.