Enum Steal
#[must_use]
pub enum Steal<T>
Possible outcomes of a steal operation.
Examples
There are lots of ways to chain results of steal operations together:
use ;
let collect = ;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Variants
-
Empty The queue was empty at the time of stealing.
-
Success(T) At least one task was successfully stolen.
-
Retry The steal operation needs to be retried.
Implementations
impl<T> Steal<T>
fn is_empty(&self) -> boolReturns
trueif the queue was empty at the time of stealing.Examples
use ; assert!; assert!; assert!;fn is_success(&self) -> boolReturns
trueif at least one task was stolen.Examples
use ; assert!; assert!; assert!;fn is_retry(&self) -> boolReturns
trueif the steal operation needs to be retried.Examples
use ; assert!; assert!; assert!;fn success(self) -> Option<T>Returns the result of the operation, if successful.
Examples
use ; assert_eq!; assert_eq!; assert_eq!;fn or_else<F>(self, f: F) -> Steal<T> where F: FnOnce() -> Steal<T>,If no task was stolen, attempts another steal operation.
Returns this steal result if it is
Success. Otherwise, closurefis invoked and then:- If the second steal resulted in
Success, it is returned. - If both steals were unsuccessful but any resulted in
Retry, thenRetryis returned. - If both resulted in
None, thenNoneis returned.
Examples
use ; assert_eq!; assert_eq!; assert_eq!; assert_eq!; assert_eq!;- If the second steal resulted in
Trait Implementations
impl<T> Debug for Steal<T>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<T> FromIterator<Steal<T>> for Steal<T>
fn from_iter<I>(iter: I) -> Steal<T> where I: IntoIterator<Item = Steal<T>>,Consumes items until a
Successis found and returns it.If no
Successwas found, but there was at least oneRetry, then returnsRetry. Otherwise,Emptyis returned.
impl<T: Clone> Clone for Steal<T>
fn clone(&self) -> Self
impl<T: Copy> Copy for Steal<T>
impl<T: Eq> Eq for Steal<T>
impl<T: PartialEq> PartialEq for Steal<T>
fn eq(&self, other: &Self) -> bool
impl<T: PartialEq> StructuralPartialEq for Steal<T>
Auto Trait Implementations
impl<T> Freeze for Steal<T>
where
T: Freeze,
impl<T> RefUnwindSafe for Steal<T>
where
T: RefUnwindSafe,
impl<T> Send for Steal<T>
where
T: Send,
impl<T> Sync for Steal<T>
where
T: Sync,
impl<T> Unpin for Steal<T>
where
T: Unpin,
impl<T> UnsafeUnpin for Steal<T>
where
T: UnsafeUnpin,
impl<T> UnwindSafe for Steal<T>
where
T: UnwindSafe,
Blanket Implementations
impl<T> Any for Steal<T>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Steal<T>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Steal<T>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for Steal<T>
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for Steal<T>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Pointable for Steal<T>
const ALIGN: usize = _;type Init = T;unsafe fn init(init: <T as Pointable>::Init) -> usizeunsafe fn deref<'a>(ptr: usize) -> &'a Tunsafe fn deref_mut<'a>(ptr: usize) -> &'a mut Tunsafe fn drop(ptr: usize)
impl<T> ToOwned for Steal<T>
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for Steal<T>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Steal<T>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for Steal<T>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>