[][src]Struct checkers::Machine

pub struct Machine { /* fields omitted */ }

Fake machine implementation to validate an allocation history.

Methods

impl Machine[src]

pub fn push(&mut self, event: Event) -> Result<(), Violation>[src]

Push an event into the machine.

Examples

Checks for a double-free:

use checkers::{Event, Machine};

let mut machine = Machine::default();

assert!(machine.push(Event::Allocation {
    ptr: 0.into(),
    size: 2,
    align: 1,
}).is_ok());

assert!(machine.push(Event::Deallocation {
    ptr: 0.into(),
    size: 2,
    align: 1,
}).is_ok());

assert!(machine.push(Event::Deallocation {
    ptr: 0.into(),
    size: 2,
    align: 1,
}).is_err());

Checks for a misaligned allocation:

use checkers::{Event, Machine};

let mut machine = Machine::default();

assert!(machine.push(Event::Allocation {
    ptr: 5.into(),
    size: 2,
    align: 4,
}).is_err());

Tries to deallocate part of other region:

use checkers::{Event, Machine};

let mut machine = Machine::default();

assert!(machine.push(Event::Allocation {
    ptr: 100.into(),
    size: 100,
    align: 1,
}).is_ok());

assert!(machine.push(Event::Deallocation {
    ptr: 150.into(),
    size: 50,
    align: 1,
}).is_err());

assert!(machine.push(Event::Deallocation {
    ptr: 100.into(),
    size: 50,
    align: 1,
}).is_err());

pub fn trailing_regions(&self) -> Vec<Region>[src]

Access all trailing regions (ones which have not been deallocated).

Trait Implementations

impl Default for Machine[src]

Auto Trait Implementations

impl RefUnwindSafe for Machine

impl Send for Machine

impl Sync for Machine

impl Unpin for Machine

impl UnwindSafe for Machine

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.