Trait traitgraph::index::OptionalGraphIndex[][src]

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> {
    fn as_usize(self) -> Option<usize>;
fn as_usize_unchecked(self) -> usize; fn is_valid(self) -> bool { ... }
fn is_none(self) -> bool { ... }
fn is_some(self) -> bool { ... }
fn new_none() -> Self { ... } }
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

Get this index as usize, but return None if this index is marked as invalid.

A faster method to get the usize value of the index, which does not perform any validity checks.

Provided methods

Returns true if the index is valid, i.e. if it is not marked as invalid.

Returns true if the index is None.

Returns true if the index is Some.

Returns a new OptionalGraphIndex that is marked as invalid.

Implementors