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>
impl<E: Encoding, const N: usize> OrdPath<E, N>
Sourcepub fn ordinals(&self) -> Ordinals<&Bytes, &E> ⓘ
pub fn ordinals(&self) -> Ordinals<&Bytes, &E> ⓘ
Produces an iterator over the ordinals of an OrdPath.
Sourcepub fn ancestors(&self) -> Ancestors<'_, E, N> ⓘ
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);Sourcepub fn parent(&self) -> Option<&OrdPath<E, N>>
pub fn parent(&self) -> Option<&OrdPath<E, N>>
Returns the OrdPath without its final element, if there is one.
Sourcepub fn is_ancestor_of(&self, other: &Self) -> boolwhere
E: PartialEq,
pub fn is_ancestor_of(&self, other: &Self) -> boolwhere
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.
Sourcepub fn is_descendant_of(&self, other: &Self) -> boolwhere
E: PartialEq,
pub fn is_descendant_of(&self, other: &Self) -> boolwhere
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 + PartialEq, const N: usize> PartialOrd for OrdPath<E, N>
impl<E: Encoding + PartialEq, const N: usize> PartialOrd for OrdPath<E, N>
Source§impl<E: Encoding + Clone, const N: usize> ToOwned for OrdPath<E, N>
impl<E: Encoding + Clone, const N: usize> ToOwned for OrdPath<E, N>
Source§type Owned = OrdPathBuf<E, N>
type Owned = OrdPathBuf<E, N>
The resulting type after obtaining ownership.
Source§fn to_owned(&self) -> OrdPathBuf<E, N>
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)
fn clone_into(&self, target: &mut Self::Owned)
Uses borrowed data to replace owned data, usually by cloning. Read more