pub trait Cast<T: Sized = Self> {
// Required method
fn cast(&self) -> T;
}Expand description
Unary operator for casting values of one type to another.
Required Methods§
Implementations on Foreign Types§
Source§impl<E: Environment> Cast for Boolean<E>
impl<E: Environment> Cast for Boolean<E>
Source§impl<E: Environment> Cast for Field<E>
impl<E: Environment> Cast for Field<E>
Source§impl<E: Environment> Cast for Scalar<E>
impl<E: Environment> Cast for Scalar<E>
Source§impl<E: Environment> Cast for IdentifierLiteral<E>
impl<E: Environment> Cast for IdentifierLiteral<E>
Source§fn cast(&self) -> IdentifierLiteral<E>
fn cast(&self) -> IdentifierLiteral<E>
Casts an IdentifierLiteral to itself.
Source§impl<E: Environment> Cast<Address<E>> for Scalar<E>
impl<E: Environment> Cast<Address<E>> for Scalar<E>
Source§fn cast(&self) -> Address<E>
fn cast(&self) -> Address<E>
Casts a Scalar to an Address.
This operation converts the scalar to a field element, and then attempts to recover the group element by treating the field element as an x-coordinate. The group element is then converted to an address.
To cast arbitrary scalars to addresses, use Scalar::cast_lossy.
Source§impl<E: Environment> Cast<Address<E>> for IdentifierLiteral<E>
impl<E: Environment> Cast<Address<E>> for IdentifierLiteral<E>
Source§impl<E: Environment> Cast<Boolean<E>> for IdentifierLiteral<E>
impl<E: Environment> Cast<Boolean<E>> for IdentifierLiteral<E>
Source§fn cast(&self) -> Boolean<E>
fn cast(&self) -> Boolean<E>
Casts an IdentifierLiteral to a Boolean.
Note: This cast always fails because valid identifier literals cannot map
to boolean values (0x00 or 0x01). The byte 0x00 is null and 0x01 (SOH) is
not a valid identifier character. This implementation exists for uniformity
with the impl_cast_body! macro used by all literal types.
Source§impl<E: Environment> Cast<Field<E>> for IdentifierLiteral<E>
impl<E: Environment> Cast<Field<E>> for IdentifierLiteral<E>
Source§impl<E: Environment> Cast<Group<E>> for IdentifierLiteral<E>
impl<E: Environment> Cast<Group<E>> for IdentifierLiteral<E>
Source§impl<E: Environment> Cast<Scalar<E>> for IdentifierLiteral<E>
impl<E: Environment> Cast<Scalar<E>> for IdentifierLiteral<E>
Source§impl<E: Environment> Cast<IdentifierLiteral<E>> for Boolean<E>
impl<E: Environment> Cast<IdentifierLiteral<E>> for Boolean<E>
Source§fn cast(&self) -> IdentifierLiteral<E>
fn cast(&self) -> IdentifierLiteral<E>
Casts a Boolean to an IdentifierLiteral.
Note: This cast always fails because valid identifier literals cannot map
to boolean values (0x00 or 0x01). The byte 0x00 is null and 0x01 (SOH) is
not a valid identifier character. This implementation exists for uniformity
with the impl_cast_body! macro used by all literal types.
Source§impl<E: Environment> Cast<IdentifierLiteral<E>> for Field<E>
impl<E: Environment> Cast<IdentifierLiteral<E>> for Field<E>
Source§fn cast(&self) -> IdentifierLiteral<E>
fn cast(&self) -> IdentifierLiteral<E>
Casts a Field to an IdentifierLiteral.
This operation validates that the field element represents a valid identifier literal.
Source§impl<E: Environment> Cast<IdentifierLiteral<E>> for Scalar<E>
impl<E: Environment> Cast<IdentifierLiteral<E>> for Scalar<E>
Source§fn cast(&self) -> IdentifierLiteral<E>
fn cast(&self) -> IdentifierLiteral<E>
Casts a Scalar to an IdentifierLiteral.
This operation converts the scalar to a field element, and then attempts to create an identifier literal from that field element.
Source§impl<E: Environment, I0: IntegerType, I1: IntegerType> Cast<Integer<E, I1>> for Integer<E, I0>
impl<E: Environment, I0: IntegerType, I1: IntegerType> Cast<Integer<E, I1>> for Integer<E, I0>
Source§impl<E: Environment, I: IntegerType> Cast<Address<E>> for Integer<E, I>
impl<E: Environment, I: IntegerType> Cast<Address<E>> for Integer<E, I>
Source§fn cast(&self) -> Address<E>
fn cast(&self) -> Address<E>
Casts an Integer to an Address.
This operation converts the integer to a field element, and then attempts to recover the group element by treating the field element as an x-coordinate. The group element is then converted to an address.
To cast arbitrary integers to addresses, use Integer::cast_lossy.
Source§impl<E: Environment, I: IntegerType> Cast<Boolean<E>> for Integer<E, I>
impl<E: Environment, I: IntegerType> Cast<Boolean<E>> for Integer<E, I>
Source§impl<E: Environment, I: IntegerType> Cast<Field<E>> for Integer<E, I>
impl<E: Environment, I: IntegerType> Cast<Field<E>> for Integer<E, I>
Source§impl<E: Environment, I: IntegerType> Cast<Group<E>> for Integer<E, I>
impl<E: Environment, I: IntegerType> Cast<Group<E>> for Integer<E, I>
Source§impl<E: Environment, I: IntegerType> Cast<Integer<E, I>> for Boolean<E>
impl<E: Environment, I: IntegerType> Cast<Integer<E, I>> for Boolean<E>
Source§impl<E: Environment, I: IntegerType> Cast<Integer<E, I>> for Field<E>
impl<E: Environment, I: IntegerType> Cast<Integer<E, I>> for Field<E>
Source§impl<E: Environment, I: IntegerType> Cast<Integer<E, I>> for Scalar<E>
impl<E: Environment, I: IntegerType> Cast<Integer<E, I>> for Scalar<E>
Source§impl<E: Environment, I: IntegerType> Cast<Integer<E, I>> for IdentifierLiteral<E>
impl<E: Environment, I: IntegerType> Cast<Integer<E, I>> for IdentifierLiteral<E>
Source§impl<E: Environment, I: IntegerType> Cast<Scalar<E>> for Integer<E, I>
impl<E: Environment, I: IntegerType> Cast<Scalar<E>> for Integer<E, I>
Source§impl<E: Environment, I: IntegerType> Cast<IdentifierLiteral<E>> for Integer<E, I>
impl<E: Environment, I: IntegerType> Cast<IdentifierLiteral<E>> for Integer<E, I>
Source§fn cast(&self) -> IdentifierLiteral<E>
fn cast(&self) -> IdentifierLiteral<E>
Casts an Integer to an IdentifierLiteral.