Struct trackable::History [−][src]
pub struct History<Event>(_);
The tracking history of a target.
A history is a sequence of the tracked events.
Examples
use std::fmt::{Display, Formatter, Result}; use trackable::History; struct Event(&'static str); impl Display for Event { fn fmt(&self, f: &mut Formatter) -> Result { write!(f, "event: {}", self.0) } } let mut history = History::new(); history.add(Event("foo")); history.add(Event("bar")); assert_eq!(format!("\n{}", history), r#" HISTORY: [0] event: foo [1] event: bar "#);
Methods
impl<Event> History<Event>[src]
impl<Event> History<Event>pub fn new() -> Self[src]
pub fn new() -> SelfMakes an empty history.
pub fn add(&mut self, event: Event)[src]
pub fn add(&mut self, event: Event)Adds an event to the tail of this history.
pub fn events(&self) -> &[Event][src]
pub fn events(&self) -> &[Event]Returns the tracked events in this history.
Trait Implementations
impl<Event: Debug> Debug for History<Event>[src]
impl<Event: Debug> Debug for History<Event>fn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl<Event: Clone> Clone for History<Event>[src]
impl<Event: Clone> Clone for History<Event>fn clone(&self) -> History<Event>[src]
fn clone(&self) -> History<Event>Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)1.0.0
[src]Performs copy-assignment from source. Read more
impl<Event: Display> Display for History<Event>[src]
impl<Event: Display> Display for History<Event>fn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl<Event> Default for History<Event>[src]
impl<Event> Default for History<Event>