pub enum Sentinelled<T> {
Smallest,
Normal(T),
Largest,
}
Expand description
Sentinelled<T>
wraps type T
to provide smallest (smaller than any normal T
value) and largest
(larger than ant normal T
value) sentinel value for T
.
Sentinel is a very common technique used to simplify tree/list/array algorithms. The main idea is to insert sentinel node to the beginning or/and the end, so that algorithms don’t need to handle complex edge cases.
Variants§
Implementations§
source§impl<T> Sentinelled<T>
impl<T> Sentinelled<T>
sourcepub fn is_smallest(&self) -> bool
pub fn is_smallest(&self) -> bool
Returns true if this is a Sentinelled::Smallest
, otherwise false
sourcepub fn as_normal_mut(&mut self) -> Option<&mut T>
pub fn as_normal_mut(&mut self) -> Option<&mut T>
Optionally returns mutable references to the inner fields if this is a Sentinelled::Normal
, otherwise None
sourcepub fn as_normal(&self) -> Option<&T>
pub fn as_normal(&self) -> Option<&T>
Optionally returns references to the inner fields if this is a Sentinelled::Normal
, otherwise None
sourcepub fn into_normal(self) -> Result<T, Self>
pub fn into_normal(self) -> Result<T, Self>
Returns the inner fields if this is a Sentinelled::Normal
, otherwise returns back the enum in the Err
case of the result
sourcepub fn is_largest(&self) -> bool
pub fn is_largest(&self) -> bool
Returns true if this is a Sentinelled::Largest
, otherwise false
source§impl<T> Sentinelled<T>
impl<T> Sentinelled<T>
Trait Implementations§
source§impl<T: Clone> Clone for Sentinelled<T>
impl<T: Clone> Clone for Sentinelled<T>
source§fn clone(&self) -> Sentinelled<T>
fn clone(&self) -> Sentinelled<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<T: Debug> Debug for Sentinelled<T>
impl<T: Debug> Debug for Sentinelled<T>
source§impl<T: EstimateSize> EstimateSize for Sentinelled<T>
impl<T: EstimateSize> EstimateSize for Sentinelled<T>
source§fn estimated_heap_size(&self) -> usize
fn estimated_heap_size(&self) -> usize
source§fn estimated_size(&self) -> usizewhere
Self: Sized,
fn estimated_size(&self) -> usizewhere
Self: Sized,
estimated_heap_size
and the size of Self
.source§impl<T> From<T> for Sentinelled<T>
impl<T> From<T> for Sentinelled<T>
source§impl<T> Ord for Sentinelled<T>where
T: Ord,
impl<T> Ord for Sentinelled<T>where
T: Ord,
source§impl<T: PartialEq> PartialEq for Sentinelled<T>
impl<T: PartialEq> PartialEq for Sentinelled<T>
source§impl<T> PartialOrd for Sentinelled<T>where
T: Ord,
impl<T> PartialOrd for Sentinelled<T>where
T: Ord,
impl<T: Eq> Eq for Sentinelled<T>
impl<T> StructuralPartialEq for Sentinelled<T>
Auto Trait Implementations§
impl<T> Freeze for Sentinelled<T>where
T: Freeze,
impl<T> RefUnwindSafe for Sentinelled<T>where
T: RefUnwindSafe,
impl<T> Send for Sentinelled<T>where
T: Send,
impl<T> Sync for Sentinelled<T>where
T: Sync,
impl<T> Unpin for Sentinelled<T>where
T: Unpin,
impl<T> UnwindSafe for Sentinelled<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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> FromFd for T
impl<T> FromFd for T
§impl<T> FromFilelike for T
impl<T> FromFilelike for T
§fn from_filelike(owned: OwnedFd) -> T
fn from_filelike(owned: OwnedFd) -> T
Self
from the given filelike object. Read more§fn from_into_filelike<Owned>(owned: Owned) -> Twhere
Owned: IntoFilelike,
fn from_into_filelike<Owned>(owned: Owned) -> Twhere
Owned: IntoFilelike,
Self
from the given filelike object
converted from into_owned
. Read more§impl<T> FromSocketlike for T
impl<T> FromSocketlike for T
§fn from_socketlike(owned: OwnedFd) -> T
fn from_socketlike(owned: OwnedFd) -> T
Self
from the given socketlike object.§fn from_into_socketlike<Owned>(owned: Owned) -> Twhere
Owned: IntoSocketlike,
fn from_into_socketlike<Owned>(owned: Owned) -> Twhere
Owned: IntoSocketlike,
Self
from the given socketlike object
converted from into_owned
.§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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 moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
type Err = Infallible
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>
source§impl<M> MetricVecRelabelExt for M
impl<M> MetricVecRelabelExt for M
source§fn relabel(
self,
metric_level: MetricLevel,
relabel_threshold: MetricLevel,
) -> RelabeledMetricVec<M>
fn relabel( self, metric_level: MetricLevel, relabel_threshold: MetricLevel, ) -> RelabeledMetricVec<M>
RelabeledMetricVec::with_metric_level
.source§fn relabel_n(
self,
metric_level: MetricLevel,
relabel_threshold: MetricLevel,
relabel_num: usize,
) -> RelabeledMetricVec<M>
fn relabel_n( self, metric_level: MetricLevel, relabel_threshold: MetricLevel, relabel_num: usize, ) -> RelabeledMetricVec<M>
RelabeledMetricVec::with_metric_level_relabel_n
.source§fn relabel_debug_1(
self,
relabel_threshold: MetricLevel,
) -> RelabeledMetricVec<M>
fn relabel_debug_1( self, relabel_threshold: MetricLevel, ) -> RelabeledMetricVec<M>
RelabeledMetricVec::with_metric_level_relabel_n
with metric_level
set to
MetricLevel::Debug
and relabel_num
set to 1.