pub struct SwappableFactory<T>(/* private fields */);
Expand description
#[cfg(feature = "swappable")]
A Factory
that allows for swapping inner factories dynamically.
This use a lock-free data structure for swapping.
§Examples
use factory::{CloneFactory, Factory, SwappableFactory};
let f0 = SwappableFactory::new(CloneFactory::new(32));
let f1 = f0.clone();
assert_eq!(f0.create(), 32);
assert_eq!(f1.create(), 32);
f0.swap(CloneFactory::new(50));
assert_eq!(f0.create(), 50);
assert_eq!(f1.create(), 50);
Implementations§
Source§impl<T: Factory> SwappableFactory<T>
impl<T: Factory> SwappableFactory<T>
Trait Implementations§
Source§impl<T> Clone for SwappableFactory<T>
impl<T> Clone for SwappableFactory<T>
Source§impl<T: Debug> Debug for SwappableFactory<T>
impl<T: Debug> Debug for SwappableFactory<T>
Source§impl<T: Default> Default for SwappableFactory<T>
impl<T: Default> Default for SwappableFactory<T>
Source§fn default() -> SwappableFactory<T>
fn default() -> SwappableFactory<T>
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl<T> Freeze for SwappableFactory<T>
impl<T> RefUnwindSafe for SwappableFactory<T>
impl<T> Send for SwappableFactory<T>
impl<T> Sync for SwappableFactory<T>
impl<T> Unpin for SwappableFactory<T>
impl<T> UnwindSafe for SwappableFactory<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