pub struct TrackedObject<T> { /* private fields */ }Expand description
Your tracked object.
A tracked object contains reference counting logic and an
Arc to your object. It is cloneable but calling clone will
not clone your internal object.
Your object cannot be mutated. You can borrow it using
the Deref interface.
Implementations§
Source§impl<T> TrackedObject<T>
impl<T> TrackedObject<T>
Sourcepub fn map<F>(&self, f: F) -> TrackedObject<T>
pub fn map<F>(&self, f: F) -> TrackedObject<T>
Creates a new object from an existing one.
The new object will be registered in your original object’s inventory.
use census::{Inventory, TrackedObject};
let inventory = Inventory::new();
let seven = inventory.track(7);
let fourteen = seven.map(|i| i * 2);
assert_eq!(*fourteen, 14);
let living_instances = inventory.list();
assert_eq!(living_instances.len(), 2);Trait Implementations§
Source§impl<T> AsRef<T> for TrackedObject<T>
impl<T> AsRef<T> for TrackedObject<T>
Source§impl<T> Borrow<T> for TrackedObject<T>
impl<T> Borrow<T> for TrackedObject<T>
Source§impl<T> Clone for TrackedObject<T>where
T: Clone,
impl<T> Clone for TrackedObject<T>where
T: Clone,
Source§fn clone(&self) -> TrackedObject<T>
fn clone(&self) -> TrackedObject<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T> Debug for TrackedObject<T>where
T: Debug,
impl<T> Debug for TrackedObject<T>where
T: Debug,
Source§impl<T> Deref for TrackedObject<T>
impl<T> Deref for TrackedObject<T>
Source§impl From<TrackedObject<InnerSegmentMeta>> for SegmentMeta
impl From<TrackedObject<InnerSegmentMeta>> for SegmentMeta
Source§fn from(tracked: TrackedObject<InnerSegmentMeta>) -> SegmentMeta
fn from(tracked: TrackedObject<InnerSegmentMeta>) -> SegmentMeta
Converts to this type from the input type.
Auto Trait Implementations§
impl<T> Freeze for TrackedObject<T>
impl<T> RefUnwindSafe for TrackedObject<T>where
T: RefUnwindSafe,
impl<T> Send for TrackedObject<T>
impl<T> Sync for TrackedObject<T>
impl<T> Unpin for TrackedObject<T>
impl<T> UnwindSafe for TrackedObject<T>where
T: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T, A> DynAccess<T> for A
impl<T, A> DynAccess<T> for A
Source§fn load(&self) -> DynGuard<T>
fn load(&self) -> DynGuard<T>
The equivalent of
Access::load.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more