pub struct Instance<T: PartialEq> { /* private fields */ }
Expand description
instance to be selected
require the data to be stored impl PartialEq
example:
use async_wrr_queue::Instance;
use std::num::NonZeroUsize;
Instance::new("string");
Instance::new(123);
Instance::new_with_weight(String::from("String"), NonZeroUsize::new(2).unwrap());
let instance: Instance<_> = ("data", 3usize).into();
assert_eq!(&"data", instance.data());
assert_eq!(&NonZeroUsize::new(3).unwrap(), instance.weight());
Implementations§
Source§impl<T: PartialEq> Instance<T>
impl<T: PartialEq> Instance<T>
pub fn new(data: T) -> Self
pub fn new_with_weight(data: T, weight: NonZeroUsize) -> Self
pub fn data(&self) -> &T
pub fn weight(&self) -> &NonZeroUsize
Trait Implementations§
impl<T: Eq + PartialEq> Eq for Instance<T>
impl<T: PartialEq> StructuralPartialEq for Instance<T>
Auto Trait Implementations§
impl<T> Freeze for Instance<T>where
T: Freeze,
impl<T> RefUnwindSafe for Instance<T>where
T: RefUnwindSafe,
impl<T> Send for Instance<T>where
T: Send,
impl<T> Sync for Instance<T>where
T: Sync,
impl<T> Unpin for Instance<T>where
T: Unpin,
impl<T> UnwindSafe for Instance<T>where
T: UnwindSafe,
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