Struct OrdPath

Source
pub struct OrdPath<E: Encoding, const N: usize> { /* private fields */ }
Expand description

A slice of an OrdPath.

Implementations§

Source§

impl<E: Encoding, const N: usize> OrdPath<E, N>

Source

pub fn encoding(&self) -> &E

Returns a reference to the used encoding.

Source

pub fn bytes(&self) -> &Bytes

Produces an iterator over the bytes of an OrdPath.

Source

pub fn ordinals(&self) -> Ordinals<&Bytes, &E>

Produces an iterator over the ordinals of an OrdPath.

Source

pub fn ancestors(&self) -> Ancestors<'_, E, N>

Produces an iterator over OrdPath ancestors.

The iterator will yield the OrdPath that is returned if the [parent] method is used one or more times. If the [parent] method returns None, the iterator will do likewise.

§Examples
let path = <OrdPathBuf>::from_ordinals(&[1, 2, 3], DefaultEncoding);
let mut ancestors = path.ancestors();
assert_eq!(ancestors.next().map(|p| p.to_string()), Some("1.2".to_owned()));
assert_eq!(ancestors.next().map(|p| p.to_string()), Some("1".to_owned()));
assert_eq!(ancestors.next().map(|p| p.to_string()), Some("".to_owned()));
assert_eq!(ancestors.next(), None);
Source

pub fn parent(&self) -> Option<&OrdPath<E, N>>

Returns the OrdPath without its final element, if there is one.

Source

pub fn is_ancestor_of(&self, other: &Self) -> bool
where E: PartialEq,

Returns true if self is an ancestor of other.

§Examples
let a = <OrdPathBuf>::from_ordinals(&[1, 2], DefaultEncoding);
let d = <OrdPathBuf>::from_ordinals(&[1, 2, 3], DefaultEncoding);
assert!(a.is_ancestor_of(&d));

See also OrdPath::is_descendant_of.

Source

pub fn is_descendant_of(&self, other: &Self) -> bool
where E: PartialEq,

Returns true if self is an descendant of other.

§Examples
let a = <OrdPathBuf>::from_ordinals(&[1, 2], DefaultEncoding);
let d = <OrdPathBuf>::from_ordinals(&[1, 2, 3], DefaultEncoding);
assert!(d.is_descendant_of(&a));

See also OrdPath::is_ancestor_of.

Trait Implementations§

Source§

impl<E: Encoding, const N: usize> Borrow<OrdPath<E, N>> for OrdPathBuf<E, N>

Source§

fn borrow(&self) -> &OrdPath<E, N>

Immutably borrows from an owned value. Read more
Source§

impl<E: Encoding, const N: usize> Debug for OrdPath<E, N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<E: Encoding, const N: usize> Display for OrdPath<E, N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<E: Encoding, const N: usize> Hash for OrdPath<E, N>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
Source§

impl<E: Encoding + PartialEq, const N: usize> PartialEq for OrdPath<E, N>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<E: Encoding + PartialEq, const N: usize> PartialOrd for OrdPath<E, N>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<E: Encoding + Clone, const N: usize> ToOwned for OrdPath<E, N>

Source§

type Owned = OrdPathBuf<E, N>

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> OrdPathBuf<E, N>

Creates owned data from borrowed data, usually by cloning. Read more
1.63.0 · Source§

fn clone_into(&self, target: &mut Self::Owned)

Uses borrowed data to replace owned data, usually by cloning. Read more

Auto Trait Implementations§

§

impl<E, const N: usize> Freeze for OrdPath<E, N>
where E: Freeze,

§

impl<E, const N: usize> RefUnwindSafe for OrdPath<E, N>
where E: RefUnwindSafe,

§

impl<E, const N: usize> !Send for OrdPath<E, N>

§

impl<E, const N: usize> !Sized for OrdPath<E, N>

§

impl<E, const N: usize> !Sync for OrdPath<E, N>

§

impl<E, const N: usize> Unpin for OrdPath<E, N>
where E: Unpin,

§

impl<E, const N: usize> UnwindSafe for OrdPath<E, N>
where E: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more