Struct starlark::values::any::StarlarkAny
source · pub struct StarlarkAny<T: Debug + Display + Send + Sync + 'static>(pub T);
Expand description
Tuple Fields§
§0: T
Implementations§
source§impl<T: Debug + Display + Send + Sync + 'static> StarlarkAny<T>
impl<T: Debug + Display + Send + Sync + 'static> StarlarkAny<T>
sourcepub fn new(x: T) -> Self
pub fn new(x: T) -> Self
Create a new StarlarkAny
value. Such a value can be allocated on a heap with
heap.alloc(StarlarkAny::new(x))
.
Trait Implementations§
source§impl<'v, T: Debug + Display + Send + Sync + 'static> AllocValue<'v> for StarlarkAny<T>
impl<'v, T: Debug + Display + Send + Sync + 'static> AllocValue<'v> for StarlarkAny<T>
source§impl<T: Debug + Display + Send + Sync + 'static> Allocative for StarlarkAny<T>
impl<T: Debug + Display + Send + Sync + 'static> Allocative for StarlarkAny<T>
source§impl<'pst, T> ProvidesStaticType<'pst> for StarlarkAny<T>
impl<'pst, T> ProvidesStaticType<'pst> for StarlarkAny<T>
§type StaticType = StarlarkAny<T>
type StaticType = StarlarkAny<T>
source§impl<'v, T: Debug + Display + Send + Sync + 'static> Serialize for StarlarkAny<T>where
Self: StarlarkValue<'v>,
impl<'v, T: Debug + Display + Send + Sync + 'static> Serialize for StarlarkAny<T>where
Self: StarlarkValue<'v>,
source§impl<'v, T: Debug + Display + Send + Sync + 'static> StarlarkValue<'v> for StarlarkAny<T>
impl<'v, T: Debug + Display + Send + Sync + 'static> StarlarkValue<'v> for StarlarkAny<T>
source§const TYPE: &'static str = "any"
const TYPE: &'static str = "any"
Return a string describing the type of self, as returned by the type()
function. Read more
source§fn get_type_value_static() -> FrozenStringValue
fn get_type_value_static() -> FrozenStringValue
Like
TYPE
, but returns a reusable FrozenStringValue
pointer to it. This function deliberately doesn’t take a heap,
as it would not be performant to allocate a new value each time. Read more§type Canonical = StarlarkAny<T>
type Canonical = StarlarkAny<T>
Two implementations of
StarlarkValue
are considered to have the same type,
if Canonical
field points to the same type. Read moresource§fn get_type_starlark_repr() -> Ty
fn get_type_starlark_repr() -> Ty
Return a string that is the representation of a type that a user would use in
type annotations. This often will be the same as
Self::TYPE
, but in
some instances it might be slightly different than what is returned by TYPE
. Read moresource§fn matches_type(&self, ty: &str) -> bool
fn matches_type(&self, ty: &str) -> bool
Is this value a match for a named type. Usually returns
true
for
values matching get_type
, but might also work for subtypes it implements.source§fn get_methods() -> Option<&'static Methods>where
Self: Sized,
fn get_methods() -> Option<&'static Methods>where
Self: Sized,
Get the members associated with this type, accessible via
this_type.x
.
These members will have dir
/getattr
/hasattr
properly implemented,
so it is the preferred way to go if possible. See
MethodsStatic
for an example of how
to define this method.source§fn documentation(&self) -> Option<DocItem>where
Self: Sized,
fn documentation(&self) -> Option<DocItem>where
Self: Sized,
Return structured documentation for self, if available.
source§fn typechecker_ty(&self) -> Option<Ty>
fn typechecker_ty(&self) -> Option<Ty>
Type of this instance for typechecker.
Note this can be more precise than generic type.
source§fn collect_repr(&self, collector: &mut String)
fn collect_repr(&self, collector: &mut String)
Return a string representation of self, as returned by the
repr()
function.
Defaults to the Display
instance - which should be fine for nearly all types.
In many cases the repr()
representation will also be a Starlark expression
for creating the value. Read moresource§fn collect_repr_cycle(&self, collector: &mut String)
fn collect_repr_cycle(&self, collector: &mut String)
Invoked to print
repr
when a cycle is the object stack is detected.source§fn name_for_call_stack(&self, me: Value<'v>) -> String
fn name_for_call_stack(&self, me: Value<'v>) -> String
String used when printing call stack.
repr(self)
by default.source§fn to_bool(&self) -> bool
fn to_bool(&self) -> bool
Convert self to a boolean, as returned by the bool() function.
The default implementation returns
true
.source§fn write_hash(&self, hasher: &mut StarlarkHasher) -> Result<()>
fn write_hash(&self, hasher: &mut StarlarkHasher) -> Result<()>
Return a hash data for self to be used when self is placed as a key in a
Dict
.
Return an Err
if there is no hash for this value (e.g. list).
Must be stable between frozen and non-frozen values.source§fn invoke(
&self,
_me: Value<'v>,
_args: &Arguments<'v, '_>,
_eval: &mut Evaluator<'v, '_>
) -> Result<Value<'v>>
fn invoke( &self, _me: Value<'v>, _args: &Arguments<'v, '_>, _eval: &mut Evaluator<'v, '_> ) -> Result<Value<'v>>
Directly invoke a function.
The number of
named
and names
arguments are guaranteed to be equal. Read moresource§fn at(&self, index: Value<'v>, _heap: &'v Heap) -> Result<Value<'v>>
fn at(&self, index: Value<'v>, _heap: &'v Heap) -> Result<Value<'v>>
Return the result of
a[index]
if a
is indexable.source§fn at2(
&self,
_index0: Value<'v>,
_index1: Value<'v>,
_heap: &'v Heap,
_private: Private
) -> Result<Value<'v>>
fn at2( &self, _index0: Value<'v>, _index1: Value<'v>, _heap: &'v Heap, _private: Private ) -> Result<Value<'v>>
Return the result of
a[index0, index1]
if a
is indexable by two parameters.source§fn slice(
&self,
_start: Option<Value<'v>>,
_stop: Option<Value<'v>>,
_stride: Option<Value<'v>>,
_heap: &'v Heap
) -> Result<Value<'v>>
fn slice( &self, _start: Option<Value<'v>>, _stop: Option<Value<'v>>, _stride: Option<Value<'v>>, _heap: &'v Heap ) -> Result<Value<'v>>
Extract a slice of the underlying object if the object is indexable. The
result will be object between
start
and stop
(both of them are
added length() if negative and then clamped between 0 and length()).
stride
indicates the direction. Read moresource§fn iterate_collect(&self, _heap: &'v Heap) -> Result<Vec<Value<'v>>>
fn iterate_collect(&self, _heap: &'v Heap) -> Result<Vec<Value<'v>>>
Implement iteration over the value of this container by providing
the values in a
Vec
.source§unsafe fn iterate(&self, _me: Value<'v>, heap: &'v Heap) -> Result<Value<'v>>
unsafe fn iterate(&self, _me: Value<'v>, heap: &'v Heap) -> Result<Value<'v>>
Returns an iterator over the value of this container if this value holds
an iterable container. Read more
source§unsafe fn iter_size_hint(&self, _index: usize) -> (usize, Option<usize>)
unsafe fn iter_size_hint(&self, _index: usize) -> (usize, Option<usize>)
Returns the size hint for the iterator.
source§unsafe fn iter_next(&self, _index: usize, _heap: &'v Heap) -> Option<Value<'v>>
unsafe fn iter_next(&self, _index: usize, _heap: &'v Heap) -> Option<Value<'v>>
Yield the next value from the iterator. Read more
source§fn get_attr(&self, _attribute: &str, _heap: &'v Heap) -> Option<Value<'v>>
fn get_attr(&self, _attribute: &str, _heap: &'v Heap) -> Option<Value<'v>>
Get an attribute for the current value as would be returned by dotted
expression (i.e.
a.attribute
). Read moresource§fn get_attr_hashed(
&self,
attribute: Hashed<&str>,
heap: &'v Heap
) -> Option<Value<'v>>
fn get_attr_hashed( &self, attribute: Hashed<&str>, heap: &'v Heap ) -> Option<Value<'v>>
A version of
get_attr
which takes BorrowHashed<str>
instead of &str
,
thus implementation may reuse the hash of the string if this is called
repeatedly with the same string. Read moresource§fn has_attr(&self, attribute: &str, heap: &'v Heap) -> bool
fn has_attr(&self, attribute: &str, heap: &'v Heap) -> bool
Return true if an attribute of name
attribute
exists for the current
value. Read moresource§fn dir_attr(&self) -> Vec<String>
fn dir_attr(&self) -> Vec<String>
Return a vector of string listing all attribute of the current value. Read more
source§fn is_in(&self, other: Value<'v>) -> Result<bool>
fn is_in(&self, other: Value<'v>) -> Result<bool>
Tell whether
other
is in the current value, if it is a container. Read moresource§fn plus(&self, _heap: &'v Heap) -> Result<Value<'v>>
fn plus(&self, _heap: &'v Heap) -> Result<Value<'v>>
Apply the
+
unary operator to the current value. Read moresource§fn minus(&self, _heap: &'v Heap) -> Result<Value<'v>>
fn minus(&self, _heap: &'v Heap) -> Result<Value<'v>>
Apply the
-
unary operator to the current value. Read moresource§fn radd(&self, _lhs: Value<'v>, _heap: &'v Heap) -> Option<Result<Value<'v>>>
fn radd(&self, _lhs: Value<'v>, _heap: &'v Heap) -> Option<Result<Value<'v>>>
Add with the arguments the other way around. Should return
None
to fall through to normal add.source§fn add(&self, _rhs: Value<'v>, _heap: &'v Heap) -> Option<Result<Value<'v>>>
fn add(&self, _rhs: Value<'v>, _heap: &'v Heap) -> Option<Result<Value<'v>>>
Add
other
to the current value. Pass both self and
the Value form of self as original. Read moresource§fn sub(&self, other: Value<'v>, _heap: &'v Heap) -> Result<Value<'v>>
fn sub(&self, other: Value<'v>, _heap: &'v Heap) -> Result<Value<'v>>
Subtract
other
from the current value. Read moresource§fn rmul(&self, lhs: Value<'v>, heap: &'v Heap) -> Option<Result<Value<'v>>>
fn rmul(&self, lhs: Value<'v>, heap: &'v Heap) -> Option<Result<Value<'v>>>
Called on
rhs
of lhs * rhs
when lhs.mul
returns None
.source§fn mul(&self, _rhs: Value<'v>, _heap: &'v Heap) -> Option<Result<Value<'v>>>
fn mul(&self, _rhs: Value<'v>, _heap: &'v Heap) -> Option<Result<Value<'v>>>
Multiply the current value with
other
. Read moresource§fn div(&self, other: Value<'v>, _heap: &'v Heap) -> Result<Value<'v>>
fn div(&self, other: Value<'v>, _heap: &'v Heap) -> Result<Value<'v>>
Divide the current value by
other
. Always results in a float value. Read moresource§fn percent(&self, other: Value<'v>, _heap: &'v Heap) -> Result<Value<'v>>
fn percent(&self, other: Value<'v>, _heap: &'v Heap) -> Result<Value<'v>>
Apply the percent operator between the current value and
other
. Usually used on
strings, as per
the Starlark spec. Read moresource§fn floor_div(&self, other: Value<'v>, _heap: &'v Heap) -> Result<Value<'v>>
fn floor_div(&self, other: Value<'v>, _heap: &'v Heap) -> Result<Value<'v>>
Floor division between the current value and
other
. Read moresource§fn bit_or(&self, other: Value<'v>, _heap: &'v Heap) -> Result<Value<'v>>
fn bit_or(&self, other: Value<'v>, _heap: &'v Heap) -> Result<Value<'v>>
Bitwise
|
operator. Read moresource§fn left_shift(&self, other: Value<'v>, _heap: &'v Heap) -> Result<Value<'v>>
fn left_shift(&self, other: Value<'v>, _heap: &'v Heap) -> Result<Value<'v>>
Bitwise
<<
operator.source§fn right_shift(&self, other: Value<'v>, _heap: &'v Heap) -> Result<Value<'v>>
fn right_shift(&self, other: Value<'v>, _heap: &'v Heap) -> Result<Value<'v>>
Bitwise
>>
operator.source§fn rbin_op_ty(_lhs: &TyBasic, _op: TypingBinOp) -> Option<Ty>
fn rbin_op_ty(_lhs: &TyBasic, _op: TypingBinOp) -> Option<Ty>
Typecheck
lhs op this
.source§fn export_as(
&self,
_variable_name: &str,
_eval: &mut Evaluator<'v, '_>
) -> Result<()>
fn export_as( &self, _variable_name: &str, _eval: &mut Evaluator<'v, '_> ) -> Result<()>
Called when exporting a value under a specific name,
source§fn set_at(&self, _index: Value<'v>, _new_value: Value<'v>) -> Result<()>
fn set_at(&self, _index: Value<'v>, _new_value: Value<'v>) -> Result<()>
Set the value at
index
with the new value. Read moreAuto Trait Implementations§
impl<T> RefUnwindSafe for StarlarkAny<T>where
T: RefUnwindSafe,
impl<T> Send for StarlarkAny<T>
impl<T> Sync for StarlarkAny<T>
impl<T> Unpin for StarlarkAny<T>where
T: Unpin,
impl<T> UnwindSafe for StarlarkAny<T>where
T: UnwindSafe,
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<T> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>
source§impl<'v, T> StarlarkTypeRepr for Twhere
T: StarlarkValue<'v> + ?Sized,
impl<'v, T> StarlarkTypeRepr for Twhere
T: StarlarkValue<'v> + ?Sized,
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