Struct Trace

Source
pub struct Trace(/* private fields */);
Expand description

A backtrace-like structure to store traces.

Implementations§

Source§

impl Trace

Source

pub fn new() -> Self

Create a new empty Trace.

Source

pub fn add<D>(&mut self, trace: D)
where D: Display + Send + Sync + 'static,

Add trace.

§Example
let mut trace = Trace::new();

trace.add("item 1");
trace.add("item 2");
Source

pub fn iter(&self) -> TraceIter<'_>

Get an iterator over all traces.

The returned iterator iterates over all traces in the reverse order they were added.

§Example
let mut trace = Trace::new();

trace.add("item 1");
trace.add("item 2");

let mut iter = trace.iter().map(|x| x.to_string());
assert_eq!(iter.next().as_deref(), Some("item 2"));
assert_eq!(iter.next().as_deref(), Some("item 1"));
assert_eq!(iter.next(), None);

Trait Implementations§

Source§

impl Debug for Trace

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Trace

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Trace

§

impl !RefUnwindSafe for Trace

§

impl Send for Trace

§

impl Sync for Trace

§

impl Unpin for Trace

§

impl !UnwindSafe for Trace

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

Source§

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.