Struct creusot_contracts::logic::Mapping

source ·
pub struct Mapping<A: ?Sized, B: ?Sized>(/* 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: ?Sized> Mapping<A, B>

source

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

Get the value associated with a in the map.

logic

source

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

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

logic

source

pub fn cst(b: B) -> Self

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

logic

Trait Implementations§

source§

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

source§

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

logic

self.get(a)

§

type Item = B

Auto Trait Implementations§

§

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

§

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

§

impl<A, B> !Send for Mapping<A, B>

§

impl<A, B> !Sync for Mapping<A, B>

§

impl<A, B> !Unpin for Mapping<A, B>

§

impl<A, B> !UnwindSafe for Mapping<A, B>

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> MakeSized for T
where T: ?Sized,

source§

fn make_sized(&self) -> Box<T>

logic

ensures

*result == *self

source§

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

§

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

§

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.