Struct simplicity::types::Type
source · 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 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 bind(&self, bound: Arc<Bound>, hint: &'static str) -> Result<(), Error>
pub fn bind(&self, bound: Arc<Bound>, hint: &'static str) -> Result<(), Error>
Binds the type to a given bound. If this fails, attach the provided hint to the error.
Fails if the type has an existing incompatible bound.
sourcepub fn unify(&self, other: &Self, hint: &'static str) -> Result<(), Error>
pub fn unify(&self, other: &Self, hint: &'static str) -> Result<(), Error>
Unify the type with another one.
Fails if the bounds on the two types are incompatible
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(n: usize) -> Vec<Self>
pub fn powers_of_two(n: usize) -> Vec<Self>
Return a vector containing the types 2^(2^i) for i from 0 to n-1.