Struct debugtrace::Trace
[−]
[src]
pub struct Trace<T>(_, _);
Wrapper type containing a value and the backtrace to the address where it was wrapped.
It is transparent and forwards Hash
, PartialOrd
, Ord
, PartialEq
and Eq
to the
wrapped type. Deref
and DerefMut
implementations are provided to make it somewhat easy
to work with the contained type.
Methods
impl<T> Trace<T>
[src]
fn new(t: T) -> Self
Creates a new stack-trace wrapping a value.
use debugtrace::Trace; fn foo() -> Trace<()> { Trace::new(()) } let t = foo(); // Prints "() at:" followed by a backtrace in debug and test profiles // Will also print the backtrace if the `backtrace` feature is on // independent of profile println!("{:?}", t);
fn unwrap(self) -> T
Discards the information about where this trace was constructed and yields the wrapped data.
use debugtrace::Trace; let t = Trace::new("my error"); assert_eq!(t.unwrap(), "my error");
Trait Implementations
impl<T: Clone> Clone for Trace<T>
[src]
fn clone(&self) -> Trace<T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<T> From<T> for Trace<T>
[src]
Enables any error to automatically be wrapped in Trace<E>
when Result<T, E>
is used in
the try!
macro.
fn from(t: T) -> Self
Performs the conversion.
impl<T: Debug> Debug for Trace<T>
[src]
Implementation of debug which debug-prints the inner type followed by the stacktrace to the
address where the Trace
was created.
impl<T> Deref for Trace<T>
[src]
type Target = T
The resulting type after dereferencing
fn deref(&self) -> &T
The method called to dereference a value
impl<T> DerefMut for Trace<T>
[src]
fn deref_mut(&mut self) -> &mut T
The method called to mutably dereference a value
impl<T: Hash> Hash for Trace<T>
[src]
fn hash<H>(&self, state: &mut H) where
H: Hasher,
H: Hasher,
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<T: PartialOrd> PartialOrd for Trace<T>
[src]
fn partial_cmp(&self, rhs: &Trace<T>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<T: Ord> Ord for Trace<T>
[src]
fn cmp(&self, rhs: &Self) -> Ordering
This method returns an Ordering
between self
and other
. Read more
impl<T: PartialEq> PartialEq<Trace<T>> for Trace<T>
[src]
fn eq(&self, rhs: &Trace<T>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.