Mapping

Struct Mapping 

Source
pub struct Mapping<A: ?Sized, B>(/* private fields */);
Expand description

A mapping: map every value of type A to a value of type B.

§Pearlite syntax

Mappings have special support in pearlite code: you may write a closure to create a mapping.

§Example

let value = snapshot!(4);
let map: Snapshot<Mapping<Int, Int>> = snapshot!(|n| if n % 2 == 0 { 0 } else { *value });
proof_assert!(map.get(1) == 4);

Implementations§

Source§

impl<A: ?Sized, B> Mapping<A, B>

Source

pub fn get(self, a: A) -> B

Get the value associated with a in the map.

Source

pub fn set(self, a: A, b: B) -> Self

Returns a new mapping, where a is now mapped to b.

Source

pub fn cst(b: B) -> Self

Create a mapping, where every value of type a is mapped to b.

Source

pub fn ext_eq(self, x: Self) -> bool

Extensional equality.

Returns true if self and other contain exactly the same key-value pairs.

This is in fact equivalent with normal equality.

Trait Implementations§

Source§

impl<A: ?Sized, B> IndexLogic<A> for Mapping<A, B>

Source§

fn index_logic(self, a: A) -> B

(open, inline)

self.get(a)

Source§

type Item = B

Auto Trait Implementations§

§

impl<A, B> Freeze for Mapping<A, B>
where A: ?Sized,

§

impl<A, B> RefUnwindSafe for Mapping<A, B>

§

impl<A, B> Send for Mapping<A, B>
where A: Send + ?Sized, B: Send,

§

impl<A, B> Sync for Mapping<A, B>
where A: Sync + ?Sized, B: Sync,

§

impl<A, B> Unpin for Mapping<A, B>
where A: Unpin + ?Sized, B: Unpin,

§

impl<A, B> UnwindSafe for Mapping<A, B>
where A: UnwindSafe + ?Sized, B: 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.