Struct checkers::Events[][src]

pub struct Events { /* fields omitted */ }
Expand description

Collections of events.

We use a wrapper type to provide convenience methods for diagnostics.

Implementations

Construct a new collection of allocations.

Get the number of events in this collection.

Test if collection is empty.

Access the capacity of the Events container.

Reserve extra capacity for the underlying storage.

Fetch all allocations as a slice.

Fetch all allocations as a slice.

Clear the collection of events.

Push a single event into the collection of events.

Examples

use checkers::{Event::*, Request, Events, Region};
let mut events = Events::new();

let request = Request::without_backtrace(Region::new(10.into(), 10, 1));
events.push(Alloc(request));

assert!(matches!(&events[0], &Alloc(..)));

Count the number of allocations in this collection of events.

Examples

use checkers::{Event::*, Request, Events, Event, Region};
let mut events = Events::new();

let request = Request::without_backtrace(Region::new(10.into(), 10, 1));
events.push(Alloc(request));

assert_eq!(1, events.allocs());
assert_eq!(0, events.frees());

Count the number of allocations in this collection of events.

Examples

use checkers::{Event::*, Request, Events, Region, Realloc};
let mut events = Events::new();

events.push(Realloc(Realloc::without_backtrace(
    Some(true),
    Region::new(10.into(), 10, 1),
    Region::new(20.into(), 10, 1)
)));

assert_eq!(1, events.reallocs());
assert_eq!(0, events.allocs());
assert_eq!(0, events.frees());

Count the number of frees in this collection of events.

Examples

use checkers::{Event::*, Events, Region, Request};
let mut events = Events::new();

let request = Request::without_backtrace(Region::new(10.into(), 10, 1));
events.push(Free(request));

assert_eq!(0, events.allocs());
assert_eq!(1, events.frees());

Validate the current state and populate the errors collection with any violations found.

See Machine::push for more details on the kind of validation errors that can be raised.

Max amount of memory used according to this event history.

Returns the first violation encountered if the history is not sound.

Examples

use checkers::{Event::*, Events, Region, Request};
let mut events = Events::new();

let request = Request::without_backtrace(Region::new(0x10.into(), 0x10, 1));
events.push(Alloc(request));

let request = Request::without_backtrace(Region::new(0x20.into(), 0x10, 1));
events.push(Alloc(request));

let request = Request::without_backtrace(Region::new(0x10.into(), 0x10, 1));
events.push(Free(request));

assert_eq!(0x20, events.max_memory_used().unwrap());

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.