[−][src]Struct checkers::Machine
Fake machine implementation to validate an allocation history.
Fields
memory_used: usize
Current memory used according to allocations.
Implementations
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::*, Region, Machine}; let mut machine = Machine::default(); assert!(machine.push(Alloc(Region::new(0.into(), 2, 1))).is_ok()); assert!(machine.push(Free(Region::new(0.into(), 2, 1))).is_ok()); assert!(machine.push(Free(Region::new(0.into(), 2, 1))).is_err());
Check for a misaligned allocation:
use checkers::{Event::*, Region, Machine, Violation}; let mut machine = Machine::default(); let requested = Region::new(5.into(), 2, 4); assert_eq!( Err(Violation::MisalignedAlloc { requested }), machine.push(Alloc(requested)) );
Tries to deallocate part of other region:
use checkers::{Event::*, Region, Machine, Violation}; let mut machine = Machine::default(); let existing = Region::new(100.into(), 100, 1); assert!(machine.push(Alloc(existing)).is_ok()); let requested = Region::new(150.into(), 50, 1); assert_eq!( Err(Violation::MissingFree { requested }), machine.push(Free(requested)) ); let requested = Region::new(100.into(), 50, 1); assert_eq!( Err(Violation::IncompleteFree { requested, existing }), machine.push(Free(requested)) );
pub fn trailing_regions(&self) -> Vec<Region>
[src]
Access all trailing regions (ones which have not been deallocated).
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Machine
[src]
impl Send for Machine
[src]
impl Sync for Machine
[src]
impl Unpin for Machine
[src]
impl UnwindSafe for Machine
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,