pub struct ConstrainedTy {
pub matching_source: Fragment,
pub base_ty: Box<Type>,
pub constraining_items: Vec<Path>,
}
Available on crate feature
ast-models
only.Expand description
A type with a given set of constraints.
Constraints in wright are functions that the compiler can verify are strictly pure (which is informally defined here, and a point of further work eventually).
A constrained type declaration lists a base type and then one or more “strictly pure” functions that have a signature exactly matching T -> bool (where T is the constrained type).
An example of this could be
pure func is_even(i: u8) -> bool {
i % 2 == 0
}
type EvenU8 = u8 constrain is_even;
The wright compiler can then optimize agressively around these constraints later on (I hope).
Fields§
§matching_source: Fragment
The entire type signature from the beginning of the base type to the end of the last constraining item.
base_ty: Box<Type>
The type being constrained.
constraining_items: Vec<Path>
The functions constraining it.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ConstrainedTy
impl RefUnwindSafe for ConstrainedTy
impl Send for ConstrainedTy
impl Sync for ConstrainedTy
impl Unpin for ConstrainedTy
impl UnwindSafe for ConstrainedTy
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
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>
Converts
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>
Converts
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 more