pub struct Rewrite<Lhs, Rhs, Via> { /* private fields */ }Expand description
Witness that type-level expression Lhs equals Rhs,
justified by rule Via.
Rewrite is a zero-sized type — it carries no data, only
type-level evidence that an algebraic identity has been invoked.
§Example
use karpal_proof::rewrite::*;
// Create a rewrite justified by associativity
let step: Rewrite<AssocLeft, AssocRight, ByAssociativity> =
Rewrite::witness();
// Reverse it
let _back: Rewrite<AssocRight, AssocLeft, BySymmetry<ByAssociativity>> =
step.sym();Implementations§
Source§impl<Lhs, Rhs, Via> Rewrite<Lhs, Rhs, Via>
impl<Lhs, Rhs, Via> Rewrite<Lhs, Rhs, Via>
Sourcepub fn witness() -> Selfwhere
Via: Justifies<Lhs, Rhs>,
pub fn witness() -> Selfwhere
Via: Justifies<Lhs, Rhs>,
Construct a rewrite witness.
Only compiles if Via: Justifies<Lhs, Rhs>.
Sourcepub fn sym(self) -> Rewrite<Rhs, Lhs, BySymmetry<Via>>
pub fn sym(self) -> Rewrite<Rhs, Lhs, BySymmetry<Via>>
Reverse: if Lhs = Rhs then Rhs = Lhs.
Sourcepub fn then<Rhs2, V2>(
self,
_next: Rewrite<Rhs, Rhs2, V2>,
) -> Rewrite<Lhs, Rhs2, ByTransitivity<Via, V2, Rhs>>
pub fn then<Rhs2, V2>( self, _next: Rewrite<Rhs, Rhs2, V2>, ) -> Rewrite<Lhs, Rhs2, ByTransitivity<Via, V2, Rhs>>
Chain: if Lhs = Mid (via self) and Mid = Rhs2 (via next),
then Lhs = Rhs2.
The Rhs of the first rewrite must be the same type as the
Lhs (i.e., Mid) of the second. This is enforced by sharing
the type parameter Rhs/Mid.
Auto Trait Implementations§
impl<Lhs, Rhs, Via> Freeze for Rewrite<Lhs, Rhs, Via>
impl<Lhs, Rhs, Via> RefUnwindSafe for Rewrite<Lhs, Rhs, Via>
impl<Lhs, Rhs, Via> Send for Rewrite<Lhs, Rhs, Via>
impl<Lhs, Rhs, Via> Sync for Rewrite<Lhs, Rhs, Via>
impl<Lhs, Rhs, Via> Unpin for Rewrite<Lhs, Rhs, Via>
impl<Lhs, Rhs, Via> UnsafeUnpin for Rewrite<Lhs, Rhs, Via>
impl<Lhs, Rhs, Via> UnwindSafe for Rewrite<Lhs, Rhs, Via>
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