pub trait OptionalGraphIndex<MirrorGraphIndex: GraphIndex<Self>>:
Default
+ Debug
+ Eq
+ Ord
+ Hash
+ Copy
+ Sized
+ From<usize>
+ From<Option<usize>>
+ From<MirrorGraphIndex>
+ From<Option<MirrorGraphIndex>>
+ Into<Option<MirrorGraphIndex>>
+ Add<usize, Output = Self>
+ Sub<usize, Output = Self> {
// Required methods
fn as_usize(self) -> Option<usize>;
fn as_usize_unchecked(self) -> usize;
// Provided methods
fn is_valid(self) -> bool { ... }
fn is_none(self) -> bool { ... }
fn is_some(self) -> bool { ... }
fn new_none() -> Self { ... }
fn unwrap(self) -> MirrorGraphIndex { ... }
}
Expand description
A graph index that can be None
.
This is a hack to get a small sized Option<GraphIndex>
by storing the None
variant as IndexType::max_value()
.
If Rust ever adds support for integer types with invalid values other than 0, this trait becomes obsolete.
Required Methods§
Sourcefn as_usize(self) -> Option<usize>
fn as_usize(self) -> Option<usize>
Get this index as usize
, but return None
if this index is marked as invalid.
Sourcefn as_usize_unchecked(self) -> usize
fn as_usize_unchecked(self) -> usize
A faster method to get the usize
value of the index, which does not perform any validity checks.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.