pub struct Type { /* private fields */ }
Expand description
Source or target type of a Simplicity expression.
Internally this type is essentially just a refcounted pointer; it is therefore quite cheap to clone, but be aware that cloning will not actually create a new independent type, just a second pointer to the first one.
Implementations§
Source§impl Type
impl Type
Sourcepub fn two_two_n(ctx: &Context, n: usize) -> Self
pub fn two_two_n(ctx: &Context, n: usize) -> Self
Create the type 2^(2^n)
for the given n
.
The type is precomputed and fast to access.
Sourcepub fn sum(ctx: &Context, left: Self, right: Self) -> Self
pub fn sum(ctx: &Context, left: Self, right: Self) -> Self
Create the sum of the given left
and right
types.
Sourcepub fn product(ctx: &Context, left: Self, right: Self) -> Self
pub fn product(ctx: &Context, left: Self, right: Self) -> Self
Create the product of the given left
and right
types.
Sourcepub fn shallow_clone(&self) -> Type
pub fn shallow_clone(&self) -> Type
Clones the Type
.
This is the same as just calling .clone()
but has a different name to
emphasize that what’s being cloned is merely a ref-counted pointer.
Sourcepub fn final_data(&self) -> Option<Arc<Final>>
pub fn final_data(&self) -> Option<Arc<Final>>
Accessor for the data of this type, if it is complete
Sourcepub fn is_final(&self) -> bool
pub fn is_final(&self) -> bool
Whether this type is known to be final
During type inference this may be false even though the type is, in fact,
complete, since its children may have been unified to a complete type. To
ensure a type is complete, call Type::finalize
.
Sourcepub fn finalize(&self) -> Result<Arc<Final>, Error>
pub fn finalize(&self) -> Result<Arc<Final>, Error>
Attempts to finalize the type. Returns its TMR on success.
Sourcepub fn powers_of_two(ctx: &Context, n: usize) -> Vec<Self>
pub fn powers_of_two(ctx: &Context, n: usize) -> Vec<Self>
Return a vector containing the types 2^(2^i) for i from 0 to n-1.