pub struct Family<T> { /* private fields */ }
Expand description
Represents a family of linked objects and allows you to create additional instances in the same family.
Clones represent the same family and are functionally equivalent.
§When to use this type
The family is a low-level primitive for creating instances of linked objects. You will need to use it directly if you are implementing custom instance management patterns. Typical usage of linked objects occurs via standard macros/wrappers provided by the crate:
linked::instances!
linked::thread_local_rc!
linked::thread_local_arc!
(ifT: Sync
)linked::InstancePerThread<T>
linked::InstancePerThreadSync<T>
(ifT: Sync
)
§Example
use std::thread;
use linked::Object; // This brings .family() into scope.
let thing = Thing::new("hello".to_string());
assert_eq!(thing.value(), "hello");
thing.set_value("world".to_string());
thread::spawn({
let thing_family = thing.family();
move || {
let thing: Thing = thing_family.into();
assert_eq!(thing.value(), "world");
}
})
.join()
.unwrap();
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Family<T>
impl<T> !RefUnwindSafe for Family<T>
impl<T> Send for Family<T>
impl<T> Sync for Family<T>
impl<T> Unpin for Family<T>
impl<T> !UnwindSafe for Family<T>
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