pub struct PathStack(/* private fields */);Expand description
A stack that stores sequences of LabelNameId as a single array
Internally, it is a flattened array of paths. Each sequence is made of parts represented by an id, and sequences are separated by PATH_SEPARATOR.
Parts are in the reverse order of insertion, to avoid lazily popping without peeking.
use swh_graph::labels::LabelNameId;
use swh_graph_stdlib::collections::PathStack;
let path1 = [LabelNameId(0), LabelNameId(10)];
let path2 = [LabelNameId(1)];
let mut stack = PathStack::new();
stack.push(path1);
stack.push(path2);
assert_eq!(stack.pop().unwrap().collect::<Vec<_>>(), path2);
assert_eq!(stack.pop().unwrap().collect::<Vec<_>>(), path1);
assert!(stack.pop().is_none());Implementations§
Source§impl PathStack
impl PathStack
pub fn new() -> PathStack
Sourcepub fn with_capacity(capacity: usize) -> PathStack
pub fn with_capacity(capacity: usize) -> PathStack
Creates a new empty PathStack pre-allocated for this many paths plus path parts.
Sourcepub fn push<Iter: IntoIterator<Item = LabelNameId>>(&mut self, path: Iter)
pub fn push<Iter: IntoIterator<Item = LabelNameId>>(&mut self, path: Iter)
Adds a path to this stack
§Panics
If any of the LabelNameId path parts was manually built from u64::MAX.
Sourcepub fn push_filename(&mut self, item: LabelNameId)
pub fn push_filename(&mut self, item: LabelNameId)
Adds a path part to the last path on this stack
§Panics
If the LabelNameId path parts was manually built from u64::MAX.
Sourcepub fn pop(&mut self) -> Option<PopPathStack<'_>>
pub fn pop(&mut self) -> Option<PopPathStack<'_>>
Removes the last path of this stack
Returns an iterator that pops parts from the part as the iterator is consumed. It is safe to drop the iterator without consuming it.
Trait Implementations§
impl Eq for PathStack
impl StructuralPartialEq for PathStack
Auto Trait Implementations§
impl Freeze for PathStack
impl RefUnwindSafe for PathStack
impl Send for PathStack
impl Sync for PathStack
impl Unpin for PathStack
impl UnwindSafe for PathStack
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
Mutably borrows from an owned value. Read more
Source§impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
Source§impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DowncastableFrom<T> for T
impl<T> DowncastableFrom<T> for T
Source§fn downcast_from(value: T) -> T
fn downcast_from(value: T) -> T
Truncate the current UnsignedInt to a possibly smaller size
Source§impl<T> DowncastableFrom<T> for T
impl<T> DowncastableFrom<T> for T
Source§fn downcast_from(value: T) -> T
fn downcast_from(value: T) -> T
Truncate the current UnsignedInt to a possibly smaller size
Source§impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
Source§impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
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>
Converts
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>
Converts
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> Pointable for T
impl<T> Pointable for T
Source§impl<T> UpcastableFrom<T> for T
impl<T> UpcastableFrom<T> for T
Source§fn upcast_from(value: T) -> T
fn upcast_from(value: T) -> T
Extend the current UnsignedInt to a possibly bigger size.
Source§impl<T> UpcastableFrom<T> for T
impl<T> UpcastableFrom<T> for T
Source§fn upcast_from(value: T) -> T
fn upcast_from(value: T) -> T
Extend the current UnsignedInt to a possibly bigger size.