pub enum Type {
Show 21 variants
Address,
Array(ArrayType),
Boolean,
Composite(CompositeType),
Field,
Future(FutureType),
Group,
Identifier,
DynRecord,
Ident(Identifier),
Integer(IntegerType),
Mapping(MappingType),
Optional(OptionalType),
Scalar,
Signature,
String,
Tuple(TupleType),
Vector(VectorType),
Numeric,
Unit,
Err,
}Expand description
Explicit type used for defining a variable or expression type
Variants§
Address
The address type.
Array(ArrayType)
The array type.
Boolean
The bool type.
Composite(CompositeType)
The composite type.
Field
The field type.
Future(FutureType)
The future type.
Group
The group type.
Identifier
The identifier type.
DynRecord
The dyn record type.
Ident(Identifier)
A reference to a built in type.
Integer(IntegerType)
An integer type.
Mapping(MappingType)
A mapping type.
Optional(OptionalType)
A nullable type.
Scalar
The scalar type.
Signature
The signature type.
String
The string type.
Tuple(TupleType)
A static tuple of at least one type.
Vector(VectorType)
The vector type.
Numeric
Numeric type which should be resolved to Field, Group, Integer(_), or Scalar.
Unit
The unit type.
Err
Placeholder for a type that could not be resolved or was not well-formed. Will eventually lead to a compile error.
Implementations§
Source§impl Type
impl Type
Sourcepub fn eq_user(&self, other: &Type) -> bool
pub fn eq_user(&self, other: &Type) -> bool
Are the types considered equal as far as the Leo user is concerned?
In particular, any comparison involving an Err is true, and Futures which aren’t explicit compare equal to
other Futures.
An array with an undetermined length (e.g., one that depends on a const) is considered equal to other arrays
if their element types match. This allows const propagation to potentially resolve the length before type
checking is performed again.
Composite types are considered equal if their names and resolved program names match. If either side still has const generic arguments, they are treated as equal unconditionally since monomorphization and other passes of type-checking will handle mismatches later.
Sourcepub fn eq_flat_relaxed(&self, other: &Self) -> bool
pub fn eq_flat_relaxed(&self, other: &Self) -> bool
Returns true if the self Type is equal to the other Type in all aspects besides composite program of origin.
In the case of futures, it also makes sure that if both are not explicit, they are equal.
Flattens array syntax: [[u8; 1]; 2] == [u8; (2, 1)] == true
Composite types are considered equal if their names match. If either side still has const generic arguments, they are treated as equal unconditionally since monomorphization and other passes of type-checking will handle mismatches later.
pub fn from_snarkvm<N: Network>( t: &PlaintextType<N>, program_id: ProgramId, ) -> Self
pub fn to_snarkvm<N: Network>(&self) -> Result<PlaintextType<N>>
pub fn size_in_bits<N: Network, F0, F1>(
&self,
is_raw: bool,
get_structs: F0,
get_external_structs: F1,
) -> Result<usize>where
F0: Fn(&Identifier<N>) -> Result<StructType<N>>,
F1: Fn(&Locator<N>) -> Result<StructType<N>>,
Sourcepub fn can_coerce_to(&self, expected: &Type) -> bool
pub fn can_coerce_to(&self, expected: &Type) -> bool
Determines whether self can be coerced to the expected type.
This method checks if the current type can be implicitly coerced to the expected type according to specific rules:
Optional<T>can be coerced toOptional<T>.Tcan be coerced toOptional<T>.- Arrays
[T; N]can be coerced to[Optional<T>; N]if lengths match or are unknown, and element types are coercible. - Falls back to an equality check for other types.
§Arguments
expected- The type to whichselfis being coerced.
§Returns
true if coercion is allowed; false otherwise.
pub fn is_optional(&self) -> bool
pub fn is_vector(&self) -> bool
pub fn is_mapping(&self) -> bool
pub fn to_optional(&self) -> Type
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Type
impl<'de> Deserialize<'de> for Type
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<CompositeType> for Type
impl From<CompositeType> for Type
Source§fn from(value: CompositeType) -> Self
fn from(value: CompositeType) -> Self
Source§impl From<FutureType> for Type
impl From<FutureType> for Type
Source§fn from(value: FutureType) -> Self
fn from(value: FutureType) -> Self
Source§impl From<LiteralType> for Type
impl From<LiteralType> for Type
Source§fn from(value: LiteralType) -> Self
fn from(value: LiteralType) -> Self
Source§impl From<VectorType> for Type
impl From<VectorType> for Type
Source§fn from(value: VectorType) -> Self
fn from(value: VectorType) -> Self
impl Eq for Type
impl StructuralPartialEq for Type
Auto Trait Implementations§
impl Freeze for Type
impl RefUnwindSafe for Type
impl Send for Type
impl Sync for Type
impl Unpin for Type
impl UnsafeUnpin for Type
impl UnwindSafe for Type
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<'de, T> DeserializeExt<'de> for Twhere
T: DeserializeOwned,
impl<'de, T> DeserializeExt<'de> for Twhere
T: DeserializeOwned,
fn take_from_value<D>(
value: &mut Value,
field: &str,
) -> Result<T, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);