Skip to main content

Rewrite

Struct Rewrite 

Source
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>

Source

pub fn witness() -> Self
where Via: Justifies<Lhs, Rhs>,

Construct a rewrite witness.

Only compiles if Via: Justifies<Lhs, Rhs>.

Source

pub fn sym(self) -> Rewrite<Rhs, Lhs, BySymmetry<Via>>

Reverse: if Lhs = Rhs then Rhs = Lhs.

Source

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>
where Lhs: RefUnwindSafe, Rhs: RefUnwindSafe, Via: RefUnwindSafe,

§

impl<Lhs, Rhs, Via> Send for Rewrite<Lhs, Rhs, Via>
where Lhs: Send, Rhs: Send, Via: Send,

§

impl<Lhs, Rhs, Via> Sync for Rewrite<Lhs, Rhs, Via>
where Lhs: Sync, Rhs: Sync, Via: Sync,

§

impl<Lhs, Rhs, Via> Unpin for Rewrite<Lhs, Rhs, Via>
where Lhs: Unpin, Rhs: Unpin, Via: Unpin,

§

impl<Lhs, Rhs, Via> UnsafeUnpin for Rewrite<Lhs, Rhs, Via>

§

impl<Lhs, Rhs, Via> UnwindSafe for Rewrite<Lhs, Rhs, Via>
where Lhs: UnwindSafe, Rhs: UnwindSafe, Via: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.