pub struct Ty { /* private fields */ }
Expand description
A Starlark type.
Implementations§
source§impl Ty
impl Ty
sourcepub fn as_name(&self) -> Option<&str>
pub fn as_name(&self) -> Option<&str>
Turn a type back into a name, potentially erasing some structure.
E.g. the type [bool]
would return list
.
Types like Ty::any
will return None
.
sourcepub fn ty_function(f: TyFunction) -> Self
pub fn ty_function(f: TyFunction) -> Self
Create a function type.
sourcepub fn ctor_function(type_attr: &Ty, params: Vec<Param>, result: Ty) -> Self
pub fn ctor_function(type_attr: &Ty, params: Vec<Param>, result: Ty) -> Self
Create a function, where the first argument is the result of .type
.
sourcepub const fn starlark_value<'v, T: StarlarkValue<'v>>() -> Self
pub const fn starlark_value<'v, T: StarlarkValue<'v>>() -> Self
Type from the implementation of StarlarkValue
.
sourcepub fn as_function(&self) -> Option<&TyFunction>
pub fn as_function(&self) -> Option<&TyFunction>
If this type is function, return the function type.
This is exposed for buck2 providers implementation, probably it does not do what you think.
sourcepub fn unions(xs: Vec<Self>) -> Self
pub fn unions(xs: Vec<Self>) -> Self
Create a unions type, which will be normalised before being created.
sourcepub fn iter_union(&self) -> &[TyBasic]
pub fn iter_union(&self) -> &[TyBasic]
Iterate over the types within a union, pretending the type is a singleton union if not a union.
sourcepub fn custom(t: impl TyCustomImpl) -> Self
pub fn custom(t: impl TyCustomImpl) -> Self
Create a custom type. This is called from generated code.
sourcepub fn custom_function(f: impl TyCustomFunctionImpl) -> Self
pub fn custom_function(f: impl TyCustomFunctionImpl) -> Self
Create a custom function type.
Trait Implementations§
source§impl Allocative for Ty
impl Allocative for Ty
source§impl Ord for Ty
impl Ord for Ty
source§impl PartialOrd for Ty
impl PartialOrd for Ty
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Eq for Ty
impl StructuralPartialEq for Ty
Auto Trait Implementations§
impl !RefUnwindSafe for Ty
impl Send for Ty
impl Sync for Ty
impl Unpin for Ty
impl !UnwindSafe for Ty
Blanket Implementations§
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
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.