pub enum CycleDetector<T> {
Unprocessed,
Processing,
Cyclic,
Processed(T),
}Expand description
An enum to manage potentially-cyclic computations.
Variants§
Unprocessed
We haven’t analyzed this yet.
Processing
Sentinel value that we set when starting the computation on an item. If we ever encounter this, we know we encountered a loop that we can’t handle.
Cyclic
Sentinel value we put when encountering a cycle, so we can know that happened.
Processed(T)
The final result of the computation.
Implementations§
Source§impl<T> CycleDetector<T>
impl<T> CycleDetector<T>
Sourcepub fn is_unprocessed(&self) -> bool
pub fn is_unprocessed(&self) -> bool
Returns true if this is a CycleDetector::Unprocessed, otherwise false
Sourcepub fn is_processing(&self) -> bool
pub fn is_processing(&self) -> bool
Returns true if this is a CycleDetector::Processing, otherwise false
Sourcepub fn is_cyclic(&self) -> bool
pub fn is_cyclic(&self) -> bool
Returns true if this is a CycleDetector::Cyclic, otherwise false
Sourcepub fn is_processed(&self) -> bool
pub fn is_processed(&self) -> bool
Returns true if this is a CycleDetector::Processed, otherwise false
Sourcepub fn as_processed_mut(&mut self) -> Option<&mut T>
pub fn as_processed_mut(&mut self) -> Option<&mut T>
Optionally returns mutable references to the inner fields if this is a CycleDetector::Processed, otherwise None
Sourcepub fn as_processed(&self) -> Option<&T>
pub fn as_processed(&self) -> Option<&T>
Optionally returns references to the inner fields if this is a CycleDetector::Processed, otherwise None
Sourcepub fn into_processed(self) -> Result<T, Self>
pub fn into_processed(self) -> Result<T, Self>
Returns the inner fields if this is a CycleDetector::Processed, otherwise returns back the enum in the Err case of the result
Sourcepub unsafe fn into_processed_unchecked(self) -> T
pub unsafe fn into_processed_unchecked(self) -> T
Unchecked return of the inner fields of CycleDetector::Processed.
§Safety
Results in undefined behavior when it is the incorrect variant.
Sourcepub unsafe fn as_processed_unchecked(&self) -> &T
pub unsafe fn as_processed_unchecked(&self) -> &T
Unchecked reference of the inner fields of CycleDetector::Processed.
§Safety
Results in undefined behavior when it is the incorrect variant.
Sourcepub unsafe fn as_processed_mut_unchecked(&mut self) -> &mut T
pub unsafe fn as_processed_mut_unchecked(&mut self) -> &mut T
Unchecked mutable reference of the inner fields of CycleDetector::Processed.
§Safety
Results in undefined behavior when it is the incorrect variant.
Source§impl<T> CycleDetector<T>
impl<T> CycleDetector<T>
Sourcepub fn start_processing(&mut self) -> bool
pub fn start_processing(&mut self) -> bool
If this item hadn’t been processed, return true and record it as Processing, otherwise
return false. If this item is already processing, record a cycle.
pub fn done_processing(&mut self, x: T)
Trait Implementations§
Source§impl<T: Debug> Debug for CycleDetector<T>
impl<T: Debug> Debug for CycleDetector<T>
Auto Trait Implementations§
impl<T> Freeze for CycleDetector<T>where
T: Freeze,
impl<T> RefUnwindSafe for CycleDetector<T>where
T: RefUnwindSafe,
impl<T> Send for CycleDetector<T>where
T: Send,
impl<T> Sync for CycleDetector<T>where
T: Sync,
impl<T> Unpin for CycleDetector<T>where
T: Unpin,
impl<T> UnsafeUnpin for CycleDetector<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for CycleDetector<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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
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> ⓘ
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> ⓘ
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