pub struct Path { /* private fields */ }Expand description
An immutable Willow Path. Thread-safe, cheap to clone, cheap to take prefixes of, expensive to append to (linear time complexity).
A Willow25 Path is any sequence of bytestrings — called Components — fulfilling certain constraints:
- each
Componenthas a length of at most 4096 (MCL), - each
Pathhas at most 4096 (MCC) components, and - the total size in bytes of all
Components is at most 4096 (MPL).
This type statically enforces these invariants for all (safely) created instances.
Because appending Components takes time linear in the length of the full Path, you should not build up Paths this way. Instead, use Path::from_components, Path::from_slices, Path::from_components_iter, Path::from_slices_iter, or a PathBuilder. If you statically know the path in advance, use the path! macro.
use willow25::prelude::*;
let p: Path = path!("/hi/ho");
assert_eq!(p.component_count(), 2);
assert_eq!(p.component(1), Some(Component::new(b"ho")?));
assert_eq!(p.total_length(), 4);
assert!(p.is_prefixed_by(&Path::from_slice(b"hi")?));
assert_eq!(
p.longest_common_prefix(&path!("/hi/he")),
Path::from_slice(b"hi")?
);Implementations§
Source§impl Path
impl Path
Sourcepub fn from_component(comp: &Component) -> Result<Self, PathFromComponentsError>
pub fn from_component(comp: &Component) -> Result<Self, PathFromComponentsError>
Creates a singleton Path, consisting of exactly one Component.
Copies the bytes of the Component into an owned allocation on the heap.
§Complexity
Runs in O(n), where n is the length of the Component. Performs a single allocation of O(n) bytes.
§Examples
use willow25::prelude::*;
let p = Path::from_component(component!("hi"))?;
assert_eq!(p.component_count(), 1);Sourcepub fn from_slice(comp: &[u8]) -> Result<Self, PathError>
pub fn from_slice(comp: &[u8]) -> Result<Self, PathError>
Creates a singleton Path, consisting of exactly one Component, from a raw slice of bytes.
Copies the bytes into an owned allocation on the heap.
§Complexity
Runs in O(n), where n is the length of the Component. Performs a single allocation of O(n) bytes.
§Examples
use willow25::prelude::*;
let p = Path::from_slice(b"hi")?;
assert_eq!(p.component_count(), 1);
assert_eq!(
Path::from_slice(b"too_loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong"),
Err(PathError::ComponentTooLong),
);Sourcepub fn from_components(
components: &[&Component],
) -> Result<Self, PathFromComponentsError>
pub fn from_components( components: &[&Component], ) -> Result<Self, PathFromComponentsError>
Creates a Path from a slice of Components.
Copies the bytes of the Components into an owned allocation on the heap.
§Complexity
Runs in O(n + m), where n is the total length of the created Path in bytes, and m is the number of its Components. Performs a single allocation of O(n + m) bytes.
§Examples
use willow25::prelude::*;
let components: Vec<&Component> = vec![
component!("hi"),
component!("ho"),
];
assert!(Path::from_components(&components[..]).is_ok());Sourcepub fn from_slices(slices: &[&[u8]]) -> Result<Self, PathError>
pub fn from_slices(slices: &[&[u8]]) -> Result<Self, PathError>
Create a new Path from a slice of byte slices.
§Complexity
Runs in O(n + m), where n is the total length of the created Path in bytes, and m is the number of its Components. Performs a single allocation of O(n + m) bytes.
§Example
use willow25::prelude::*;
// Ok
let path = Path::from_slices(&[b"alfie", b"notes"]).unwrap();
// Err
let result1 = Path::from_slices(&[
b"tooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo",
b"looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong",
]);
assert_eq!(result1, Err(PathError::PathTooLong));
// Err
let result2 = Path::from_slices(vec![b"".as_slice(); MCC + 1].as_slice());
assert_eq!(result2, Err(PathError::TooManyComponents));Sourcepub fn from_components_iter<'c, I>(
total_length: usize,
iter: &mut I,
) -> Result<Self, PathFromComponentsError>where
I: ExactSizeIterator<Item = &'c Component>,
pub fn from_components_iter<'c, I>(
total_length: usize,
iter: &mut I,
) -> Result<Self, PathFromComponentsError>where
I: ExactSizeIterator<Item = &'c Component>,
Creates a Path of known total length from an ExactSizeIterator of Components.
Copies the bytes of the Components into an owned allocation on the heap.
Panics if the claimed total_length does not match the sum of the lengths of all the Components.
§Complexity
Runs in O(n + m), where n is the total length of the created Path in bytes, and m is the number of its Components. Performs a single allocation of O(n + m) bytes.
§Examples
use willow25::prelude::*;
let components: Vec<&Component> = vec![
component!("hi"),
component!("ho"),
];
assert!(Path::from_components_iter(4, &mut components.into_iter()).is_ok());Sourcepub fn from_slices_iter<'a, I>(
total_length: usize,
iter: &mut I,
) -> Result<Self, PathError>where
I: ExactSizeIterator<Item = &'a [u8]>,
pub fn from_slices_iter<'a, I>(
total_length: usize,
iter: &mut I,
) -> Result<Self, PathError>where
I: ExactSizeIterator<Item = &'a [u8]>,
Creates a Path of known total length from an ExactSizeIterator of byte slices.
Copies the bytes of the Components into an owned allocation on the heap.
Panics if the claimed total_length does not match the sum of the lengths of all the Components.
§Complexity
Runs in O(n + m), where n is the total length of the created Path in bytes, and m is the number of its Components. Performs a single allocation of O(n + m) bytes.
§Examples
use willow25::prelude::*;
let components: Vec<&[u8]> = vec![b"hi", b"!"];
assert!(Path::from_slices_iter(3, &mut components.into_iter()).is_ok());Sourcepub fn append_component(
&self,
comp: &Component,
) -> Result<Self, PathFromComponentsError>
pub fn append_component( &self, comp: &Component, ) -> Result<Self, PathFromComponentsError>
Creates a new Path by appending a Component to &self.
Creates a fully separate copy of the new data on the heap; which includes cloning all data in &self. To efficiently construct Paths, use Path::from_components, Path::from_slices, Path::from_components_iter, Path::from_slices_iter, or a PathBuilder.
§Complexity
Runs in O(n + m), where n is the total length of the resulting Path in bytes, and m is the number of its Components. Performs a single allocation of O(n + m) bytes.
§Examples
use willow25::prelude::*;
let p0: Path = Path::new();
let p1 = p0.append_component(component!("hi"))?;
let p2 = p1.append_component(component!("ho"))?;
assert_eq!(
p2.append_component(component!("too_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong")),
Err(PathFromComponentsError::PathTooLong),
);Sourcepub fn append_slice(&self, comp: &[u8]) -> Result<Self, PathError>
pub fn append_slice(&self, comp: &[u8]) -> Result<Self, PathError>
Creates a new Path by appending a slice as a new Component to &self.
Creates a fully separate copy of the new data on the heap; which includes cloning all data in &self. To efficiently construct Paths, use Path::from_components, Path::from_slices, Path::from_components_iter, Path::from_slices_iter, or a PathBuilder.
§Complexity
Runs in O(n + m), where n is the total length of the resulting Path in bytes, and m is the number of its Components. Performs a single allocation of O(n + m) bytes.
§Examples
use willow25::prelude::*;
let p0: Path = Path::new();
let p1 = p0.append_slice(b"hi")?;
let p2 = p1.append_slice(b"ho")?;
assert_eq!(
p2.append_slice(b"too_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong"),
Err(PathError::PathTooLong),
);Sourcepub fn append_components(
&self,
components: &[&Component],
) -> Result<Self, PathFromComponentsError>
pub fn append_components( &self, components: &[&Component], ) -> Result<Self, PathFromComponentsError>
Creates a new Path by appending a slice of Components to &self.
Creates a fully separate copy of the new data on the heap; which includes cloning all data in &self. To efficiently construct Paths, use Path::from_components, Path::from_slices, Path::from_components_iter, Path::from_slices_iter, or a PathBuilder.
§Complexity
Runs in O(n + m), where n is the total length of the resulting Path in bytes, and m is the number of its Components. Performs a single allocation of O(n + m) bytes.
§Examples
use willow25::prelude::*;
let p0: Path = Path::new();
let p1 = p0.append_components(&[component!("hi"), component!("ho")])?;
assert_eq!(
p1.append_components(&[Component::new(b"too_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong")?]),
Err(PathFromComponentsError::PathTooLong),
);Sourcepub fn append_slices(&self, components: &[&[u8]]) -> Result<Self, PathError>
pub fn append_slices(&self, components: &[&[u8]]) -> Result<Self, PathError>
Creates a new Path by appending a slice of byte slices as new Components to &self.
Creates a fully separate copy of the new data on the heap; which includes cloning all data in &self. To efficiently construct Paths, use Path::from_components, Path::from_slices, Path::from_components_iter, Path::from_slices_iter, or a PathBuilder.
§Complexity
Runs in O(n + m), where n is the total length of the resulting Path in bytes, and m is the number of its Components. Performs a single allocation of O(n + m) bytes.
§Examples
use willow25::prelude::*;
let p0: Path = Path::new();
let p1 = p0.append_slices(&[b"hi", b"ho"])?;
assert_eq!(
p1.append_slices(&[b"too_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong"]),
Err(PathError::PathTooLong),
);Sourcepub fn append_path(&self, other: &Path) -> Result<Self, PathFromComponentsError>
pub fn append_path(&self, other: &Path) -> Result<Self, PathFromComponentsError>
Creates a new Path by appending another Path to &self.
Creates a fully separate copy of the new data on the heap; which includes cloning all data in &self and in &other.
§Complexity
Runs in O(n + m), where n is the total length of the resulting Path in bytes, and m is the number of its Components. Performs a single allocation of O(n + m) bytes.
§Examples
use willow25::prelude::*;
let p0: Path = Path::new();
let p1 = p0.append_path(&path!("/hi/ho"))?;
assert_eq!(
p1.append_path(&Path::from_slice(b"too_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong")?),
Err(PathFromComponentsError::PathTooLong),
);Sourcepub fn greater_but_not_prefixed(&self) -> Option<Self>
pub fn greater_but_not_prefixed(&self) -> Option<Self>
Returns the least Path which is strictly greater (lexicographically) than self and which is not prefixed by self; or None if no such Path exists.
§Complexity
Runs in O(n + m), where n is the total length of the Path in bytes, and m is the number of Components. Performs a single allocation of O(n + m) bytes.
Sourcepub fn component_count(&self) -> usize
pub fn component_count(&self) -> usize
Sourcepub fn total_length(&self) -> usize
pub fn total_length(&self) -> usize
Sourcepub fn total_length_of_prefix(&self, i: usize) -> usize
pub fn total_length_of_prefix(&self, i: usize) -> usize
Returns the sum of the lengths of the first i Components in &self; panics if i >= self.component_count(). More efficient than path.create_prefix(i).path_length().
Guaranteed to be at most MCC.
§Complexity
Runs in O(1), performs no allocations.
§Examples
use willow25::prelude::*;
let p: Path = path!("/hi/ho");
assert_eq!(p.total_length_of_prefix(0), 0);
assert_eq!(p.total_length_of_prefix(1), 2);
assert_eq!(p.total_length_of_prefix(2), 4);Sourcepub fn is_prefix_of(&self, other: &Self) -> bool
pub fn is_prefix_of(&self, other: &Self) -> bool
Tests whether &self is a prefix of the given Path.
Paths are always a prefix of themselves, and the empty Path is a prefix of every Path.
§Complexity
Runs in O(n + m), where n is the total length of the longer Path in bytes, and m is the greatest number of Components.
§Examples
use willow25::prelude::*;
let p: Path = path!("/hi/ho");
assert!(Path::new().is_prefix_of(&p));
assert!(path!("/hi").is_prefix_of(&p));
assert!(path!("/hi/ho").is_prefix_of(&p));
assert!(!path!("/hi/gh").is_prefix_of(&p));Sourcepub fn is_prefixed_by(&self, other: &Self) -> bool
pub fn is_prefixed_by(&self, other: &Self) -> bool
Tests whether &self is prefixed by the given Path.
Paths are always prefixed by themselves, and by the empty Path.
§Complexity
Runs in O(n + m), where n is the total length of the longer Path in bytes, and m is the greatest number of Components.
§Examples
use willow25::prelude::*;
let p: Path = path!("/hi/ho");
assert!(p.is_prefixed_by(&Path::new()));
assert!(p.is_prefixed_by(&path!("/hi")));
assert!(p.is_prefixed_by(&path!("/hi/ho")));
assert!(!p.is_prefixed_by(&path!("/hi/gh")));Tests whether &self is related to the given Path, that is, whether either one is a prefix of the other.
§Complexity
Runs in O(n + m), where n is the total length of the longer Path in bytes, and m is the greatest number of Components.
§Examples
use willow25::prelude::*;
let p: Path = Path::from_slice(b"hi")?;
assert!(p.is_related_to(&Path::new()));
assert!(p.is_related_to(&path!("/hi")));
assert!(p.is_related_to(&path!("/hi/ho")));
assert!(!p.is_related_to(&path!("/no")));Sourcepub fn prefix_cmp(&self, other: &Self) -> Option<Ordering>
pub fn prefix_cmp(&self, other: &Self) -> Option<Ordering>
Returns the Ordering describing the prefix relation between self and other.
§Complexity
Runs in O(n + m), where n is the total length of the longer Path in bytes, and m is the greatest number of Components.
§Examples
use core::cmp::Ordering;
use willow25::prelude::*;
let p: Path = Path::from_slice(b"hi")?;
assert_eq!(p.prefix_cmp(&Path::new()), Some(Ordering::Greater));
assert_eq!(p.prefix_cmp(&path!("/hi")), Some(Ordering::Equal));
assert_eq!(p.prefix_cmp(&path!("/hi/ho")), Some(Ordering::Less));
assert_eq!(p.prefix_cmp(&path!("/no")), None);Sourcepub unsafe fn component_unchecked(&self, i: usize) -> &Component
pub unsafe fn component_unchecked(&self, i: usize) -> &Component
Returns the i-th Component of &self, without checking whether i < self.component_count().
§Safety
Undefined behaviour if i >= self.component_count().
§Complexity
Runs in O(1), performs no allocations.
§Examples
use willow25::prelude::*;
let p: Path = path!("/hi/ho");
assert_eq!(unsafe { p.component_unchecked(0) }, component!("hi"));
assert_eq!(unsafe { p.component_unchecked(1) }, Component::new(b"ho")?);Sourcepub fn owned_component(&self, i: usize) -> Option<OwnedComponent>
pub fn owned_component(&self, i: usize) -> Option<OwnedComponent>
Returns an owned handle to the i-th component of &self.
§Complexity
Runs in O(1), performs no allocations.
§Examples
use willow25::prelude::*;
let p: Path = path!("/hi/ho");
assert_eq!(p.owned_component(0), Some(OwnedComponent::new(b"hi")?));
assert_eq!(p.owned_component(1), Some(OwnedComponent::new(b"ho")?));
assert_eq!(p.owned_component(2), None);Sourcepub unsafe fn owned_component_unchecked(&self, i: usize) -> OwnedComponent
pub unsafe fn owned_component_unchecked(&self, i: usize) -> OwnedComponent
Returns an owned handle to the i-th component of &self, without checking whether i < self.component_count().
§Safety
Undefined behaviour if i >= self.component_count().
§Complexity
Runs in O(1), performs no allocations.
§Examples
use willow25::prelude::*;
let p: Path = path!("/hi/ho");
assert_eq!(p.owned_component(0), Some(OwnedComponent::new(b"hi")?));
assert_eq!(p.owned_component(1), Some(OwnedComponent::new(b"ho")?));
assert_eq!(p.owned_component(2), None);Sourcepub fn components(
&self,
) -> impl DoubleEndedIterator<Item = &Component> + ExactSizeIterator<Item = &Component>
pub fn components( &self, ) -> impl DoubleEndedIterator<Item = &Component> + ExactSizeIterator<Item = &Component>
Creates an iterator over the Components of &self.
Stepping the iterator takes O(1) time and performs no memory allocations.
§Complexity
Runs in O(1), performs no allocations.
§Examples
use willow25::prelude::*;
let p: Path = path!("/hi/ho");
let mut comps = p.components();
assert_eq!(comps.next(), Some(component!("hi")));
assert_eq!(comps.next(), Some(Component::new(b"ho")?));
assert_eq!(comps.next(), None);Sourcepub fn suffix_components(
&self,
i: usize,
) -> impl DoubleEndedIterator<Item = &Component> + ExactSizeIterator<Item = &Component>
pub fn suffix_components( &self, i: usize, ) -> impl DoubleEndedIterator<Item = &Component> + ExactSizeIterator<Item = &Component>
Creates an iterator over the Components of &self, starting at the i-th Component. If i is greater than or equal to the number of Components, the iterator yields zero items.
Stepping the iterator takes O(1) time and performs no memory allocations.
§Complexity
Runs in O(1), performs no allocations.
§Examples
use willow25::prelude::*;
let p: Path = path!("/hi/ho");
let mut comps = p.suffix_components(1);
assert_eq!(comps.next(), Some(Component::new(b"ho")?));
assert_eq!(comps.next(), None);Sourcepub fn owned_components(
&self,
) -> impl DoubleEndedIterator<Item = OwnedComponent> + ExactSizeIterator<Item = OwnedComponent> + '_
pub fn owned_components( &self, ) -> impl DoubleEndedIterator<Item = OwnedComponent> + ExactSizeIterator<Item = OwnedComponent> + '_
Creates an iterator over owned handles to the components of &self.
Stepping the iterator takes O(1) time and performs no memory allocations.
§Complexity
Runs in O(1), performs no allocations.
§Examples
use willow25::prelude::*;
let p: Path = path!("/hi/ho");
let mut comps = p.owned_components();
assert_eq!(comps.next(), Some(OwnedComponent::new(b"hi")?));
assert_eq!(comps.next(), Some(OwnedComponent::new(b"ho")?));
assert_eq!(comps.next(), None);Sourcepub fn suffix_owned_components(
&self,
i: usize,
) -> impl DoubleEndedIterator<Item = OwnedComponent> + ExactSizeIterator<Item = OwnedComponent> + '_
pub fn suffix_owned_components( &self, i: usize, ) -> impl DoubleEndedIterator<Item = OwnedComponent> + ExactSizeIterator<Item = OwnedComponent> + '_
Creates an iterator over owned handles to the components of &self, starting at the i-th OwnedComponent. If i is greater than or equal to the number of OwnedComponent, the iterator yields zero items.
Stepping the iterator takes O(1) time and performs no memory allocations.
§Complexity
Runs in O(1), performs no allocations.
§Examples
use willow25::prelude::*;
let p: Path = path!("/hi/ho");
let mut comps = p.suffix_owned_components(1);
assert_eq!(comps.next(), Some(OwnedComponent::new(b"ho")?));
assert_eq!(comps.next(), None);Sourcepub fn create_prefix(&self, component_count: usize) -> Option<Self>
pub fn create_prefix(&self, component_count: usize) -> Option<Self>
Creates a new Path that consists of the first component_count Components of &self. More efficient than creating a new Path from scratch.
Returns None if component_count is greater than self.get_component_count().
§Complexity
Runs in O(1), performs no allocations.
§Examples
use willow25::prelude::*;
let p: Path = path!("/hi/ho");
assert_eq!(p.create_prefix(0), Some(Path::new()));
assert_eq!(p.create_prefix(1), Some(Path::from_slice(b"hi")?));
assert_eq!(p.create_prefix(2), Some(path!("/hi/ho")));
assert_eq!(p.create_prefix(3), None);Sourcepub unsafe fn create_prefix_unchecked(&self, component_count: usize) -> Self
pub unsafe fn create_prefix_unchecked(&self, component_count: usize) -> Self
Creates a new Path that consists of the first component_count Components of &self. More efficient than creating a new Path from scratch.
§Safety
Undefined behaviour if component_count is greater than self.component_count(). May manifest directly, or at any later
function invocation that operates on the resulting Path.
§Complexity
Runs in O(1), performs no allocations.
§Examples
use willow25::prelude::*;
let p: Path = path!("/hi/ho");
assert_eq!(unsafe { p.create_prefix_unchecked(0) }, Path::new());
assert_eq!(unsafe { p.create_prefix_unchecked(1) }, Path::from_slice(b"hi")?);
assert_eq!(unsafe { p.create_prefix_unchecked(2) }, path!("/hi/ho"));Sourcepub fn all_prefixes(&self) -> impl DoubleEndedIterator<Item = Self> + '_
pub fn all_prefixes(&self) -> impl DoubleEndedIterator<Item = Self> + '_
Creates an iterator over all prefixes of &self (including the empty Path and &self itself).
Stepping the iterator takes O(1) time and performs no memory allocations.
§Complexity
Runs in O(1), performs no allocations.
§Examples
use willow25::prelude::*;
let p: Path = path!("/hi/ho");
let mut prefixes = p.all_prefixes();
assert_eq!(prefixes.next(), Some(Path::new()));
assert_eq!(prefixes.next(), Some(Path::from_slice(b"hi")?));
assert_eq!(prefixes.next(), Some(path!("/hi/ho")));
assert_eq!(prefixes.next(), None);Sourcepub fn longest_common_prefix(&self, other: &Self) -> Self
pub fn longest_common_prefix(&self, other: &Self) -> Self
Returns the longest common prefix of &self and the given Path.
§Complexity
Runs in O(n + m), where n is the total length of the shorter of the two Paths, and m is the lesser number of Components. Performs a single allocation of O(n + m) bytes to create the return value.
§Examples
use willow25::prelude::*;
let p1: Path = path!("/hi/ho");
let p2: Path = path!("/hi/he");
assert_eq!(p1.longest_common_prefix(&p2), Path::from_slice(b"hi")?);Sourcepub unsafe fn create_slice_unchecked<R>(&self, range: R) -> Selfwhere
R: RangeBounds<usize>,
pub unsafe fn create_slice_unchecked<R>(&self, range: R) -> Selfwhere
R: RangeBounds<usize>,
Creates a Path whose Components are those of &self indexed by the given range, without checking that those components exist.
§Safety
Undefined behaviour if either the start or the end of range are explicitly greater than self.component_count(), or if range is decreasing.
§Complexity
Runs in O(1) and performs no allocations.
§Examples
use willow25::prelude::*;
let p = path!("/hi/ho");
assert_eq!(unsafe{p.create_slice_unchecked(..)}, p);
assert_eq!(unsafe{p.create_slice_unchecked(..1)}, path!("/hi"));
assert_eq!(unsafe{p.create_slice_unchecked(1..)}, path!("/ho"));
assert_eq!(unsafe{p.create_slice_unchecked(1..1)}, Path::new());Sourcepub fn create_slice<R>(&self, range: R) -> Option<Self>where
R: RangeBounds<usize>,
pub fn create_slice<R>(&self, range: R) -> Option<Self>where
R: RangeBounds<usize>,
Creates a Path whose Components are those of &self indexed by the given range.
Returns None if either the start or end of range are explicitly greater than &self.component_count() or if range is decreasing.
§Complexity
Runs in O(1) and performs no allocations.
§Examples
use willow25::prelude::*;
let p = path!("/hi/ho");
assert_eq!(p.create_slice(..), Some(p.clone()));
assert_eq!(p.create_slice(1..2), Some(path!("/ho")));
assert_eq!(p.create_slice(1..3), None);
assert_eq!(p.create_slice(2..1), None);Sourcepub unsafe fn create_suffix_unchecked(&self, component_count: usize) -> Self
pub unsafe fn create_suffix_unchecked(&self, component_count: usize) -> Self
Creates a Path whose Components are the last component_count components of &self, without checking that &self has at least component_count components.
§Safety
Undefined behaviour if component_count > self.component_count.
§Complexity
Runs in O(1) and performs no allocations.
§Examples
use willow25::prelude::*;
let p = path!("/a/b/c/d");
assert_eq!(unsafe{p.create_suffix_unchecked(2)}, path!("/c/d"));
assert_eq!(unsafe{p.create_suffix_unchecked(0)}, Path::new());Sourcepub fn create_suffix(&self, component_count: usize) -> Option<Self>
pub fn create_suffix(&self, component_count: usize) -> Option<Self>
Creates a Path whose Components are the last component_count components of &self.
Returns None if &self does not have at least component_count components.
§Complexity
Runs in O(1) and performs no allocations.
§Examples
use willow25::prelude::*;
let p = path!("/hi/ho");
assert_eq!(p.create_suffix(0), Some(Path::new()));
assert_eq!(p.create_suffix(1), Some(path!("/ho")));
assert_eq!(p.create_suffix(2), Some(path!("/hi/ho")));
assert_eq!(p.create_suffix(3), None);
Trait Implementations§
Source§impl Decodable for Path
Implements EncodePath.
impl Decodable for Path
Implements EncodePath.
Source§type ErrorReason = Blame
type ErrorReason = Blame
Source§async fn decode<P>(
producer: &mut P,
) -> Result<Self, DecodeError<P::Final, P::Error, Self::ErrorReason>>
async fn decode<P>( producer: &mut P, ) -> Result<Self, DecodeError<P::Final, P::Error, Self::ErrorReason>>
Self, or yields an error if the producer does not produce a valid encoding. Read moreSource§impl DecodableCanonic for Path
Implements encode_path.
impl DecodableCanonic for Path
Implements encode_path.
Source§type ErrorCanonic = Blame
type ErrorCanonic = Blame
Self. Read moreSource§async fn decode_canonic<P>(
producer: &mut P,
) -> Result<Self, DecodeError<P::Final, P::Error, Self::ErrorCanonic>>
async fn decode_canonic<P>( producer: &mut P, ) -> Result<Self, DecodeError<P::Final, P::Error, Self::ErrorCanonic>>
Self, and errors if the input encoding is not the canonical one.Source§impl Encodable for Path
Implements encode_path.
impl Encodable for Path
Implements encode_path.
Source§impl EncodableKnownLength for Path
Implements encode_path.
impl EncodableKnownLength for Path
Implements encode_path.
Source§fn len_of_encoding(&self) -> usize
fn len_of_encoding(&self) -> usize
self. A successful call to encode must feed exactly that many symbols into the bulk consumer.impl Eq for Path
Source§impl GreatestElement for Path
impl GreatestElement for Path
Source§fn greatest() -> Self
fn greatest() -> Self
Creates the greatest possible Path (with respect to lexicographical ordering, which is also the Ord implementation of Path).
It consists of a single component of 255 bytes, followed by 4095 empty components.
§Complexity
Runs in O(MCC + MPL). Performs a single allocation of O(MPL) bytes.
§Examples
use willow25::prelude::*;
use order_theory::GreatestElement;
let p = Path::greatest();
assert_eq!(p.component_count(), 4096);
assert_eq!(p.component(0).unwrap().len(), 4096);
assert!(p.component(1).unwrap().is_empty());
assert!(p.component(4095).unwrap().is_empty());Source§fn is_greatest(&self) -> bool
fn is_greatest(&self) -> bool
true if and only if self is the greatest element.Source§impl LeastElement for Path
The least path is the empty path.
impl LeastElement for Path
The least path is the empty path.
Source§impl LowerSemilattice for Path
impl LowerSemilattice for Path
Source§fn greatest_lower_bound(&self, other: &Self) -> Self
fn greatest_lower_bound(&self, other: &Self) -> Self
self and other, i.e., the unique greatest element in the type which is less than or equal to both self and other.Source§impl Ord for Path
Compares paths lexicographically, since that is the path ordering that the Willow spec always uses.
impl Ord for Path
Compares paths lexicographically, since that is the path ordering that the Willow spec always uses.
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Path
Compares paths lexicographically, since that is the path ordering that the Willow spec always uses.
impl PartialOrd for Path
Compares paths lexicographically, since that is the path ordering that the Willow spec always uses.
impl PredecessorExceptForLeast for Path
Source§impl RangeBounds<Path> for Range3d
impl RangeBounds<Path> for Range3d
Source§impl RelativeDecodable<Path> for Path
Implements EncodePathRelativePath.
impl RelativeDecodable<Path> for Path
Implements EncodePathRelativePath.
Source§type ErrorReason = Blame
type ErrorReason = Blame
Source§impl RelativeDecodable<Path> for CodecPathExtendsPath
Implements EncodePathExtendsPath.
impl RelativeDecodable<Path> for CodecPathExtendsPath
Implements EncodePathExtendsPath.
Source§type ErrorReason = Blame
type ErrorReason = Blame
Source§async fn relative_decode<P>(
rel: &Path,
producer: &mut P,
) -> Result<Self, DecodeError<P::Final, P::Error, Self::ErrorReason>>
async fn relative_decode<P>( rel: &Path, producer: &mut P, ) -> Result<Self, DecodeError<P::Final, P::Error, Self::ErrorReason>>
rel into a Self, or yields an error if the producer does not produce a valid relative encoding. Read moreSource§impl RelativeDecodable<PrivatePathContext> for Path
impl RelativeDecodable<PrivatePathContext> for Path
Source§type ErrorReason = Blame
type ErrorReason = Blame
Source§async fn relative_decode<P>(
rel: &PrivatePathContext,
producer: &mut P,
) -> Result<Self, DecodeError<P::Final, P::Error, Self::ErrorReason>>
async fn relative_decode<P>( rel: &PrivatePathContext, producer: &mut P, ) -> Result<Self, DecodeError<P::Final, P::Error, Self::ErrorReason>>
rel into a Self, or yields an error if the producer does not produce a valid relative encoding. Read moreSource§impl RelativeDecodableCanonic<Path> for Path
Implements path_relative_path.
impl RelativeDecodableCanonic<Path> for Path
Implements path_relative_path.
Source§type ErrorCanonic = Blame
type ErrorCanonic = Blame
Self. Read moreSource§async fn relative_decode_canonic<P>(
rel: &Path,
producer: &mut P,
) -> Result<Self, DecodeError<P::Final, P::Error, Blame>>
async fn relative_decode_canonic<P>( rel: &Path, producer: &mut P, ) -> Result<Self, DecodeError<P::Final, P::Error, Blame>>
rel into a Self, and errors if the input encoding is not the canonical one.Source§impl RelativeDecodableCanonic<Path> for CodecPathExtendsPath
Implements path_extends_path.
impl RelativeDecodableCanonic<Path> for CodecPathExtendsPath
Implements path_extends_path.
Source§type ErrorCanonic = Blame
type ErrorCanonic = Blame
Self. Read moreSource§async fn relative_decode_canonic<P>(
rel: &Path,
producer: &mut P,
) -> Result<Self, DecodeError<P::Final, P::Error, Self::ErrorReason>>
async fn relative_decode_canonic<P>( rel: &Path, producer: &mut P, ) -> Result<Self, DecodeError<P::Final, P::Error, Self::ErrorReason>>
rel into a Self, and errors if the input encoding is not the canonical one.Source§impl RelativeEncodable<Path> for Path
Implements path_rel_path.
impl RelativeEncodable<Path> for Path
Implements path_rel_path.
Source§fn can_be_encoded_relative_to(&self, _rel: &Path) -> bool
fn can_be_encoded_relative_to(&self, _rel: &Path) -> bool
Any path can be encoded relative to every path.
Source§async fn relative_encode<Consumer>(
&self,
rel: &Path,
consumer: &mut Consumer,
) -> Result<(), Consumer::Error>
async fn relative_encode<Consumer>( &self, rel: &Path, consumer: &mut Consumer, ) -> Result<(), Consumer::Error>
Source§impl RelativeEncodable<Path> for CodecPathExtendsPath
Implements path_extends_path.
impl RelativeEncodable<Path> for CodecPathExtendsPath
Implements path_extends_path.
Source§fn can_be_encoded_relative_to(&self, rel: &Path) -> bool
fn can_be_encoded_relative_to(&self, rel: &Path) -> bool
Returns true iff rel is a prefix of self.
Source§impl RelativeEncodable<PrivatePathContext> for Path
impl RelativeEncodable<PrivatePathContext> for Path
Source§fn can_be_encoded_relative_to(&self, rel: &PrivatePathContext) -> bool
fn can_be_encoded_relative_to(&self, rel: &PrivatePathContext) -> bool
Reports false if the path is not a prefix of rel.rel, OR if self is not related to to rel.private.
Source§async fn relative_encode<C>(
&self,
rel: &PrivatePathContext,
consumer: &mut C,
) -> Result<(), C::Error>
async fn relative_encode<C>( &self, rel: &PrivatePathContext, consumer: &mut C, ) -> Result<(), C::Error>
Source§impl RelativeEncodableKnownLength<Path> for Path
Implements path_rel_path.
impl RelativeEncodableKnownLength<Path> for Path
Implements path_rel_path.
Source§fn len_of_relative_encoding(&self, rel: &Path) -> usize
fn len_of_relative_encoding(&self, rel: &Path) -> usize
self, relative to rel. A successful call to relative_encode must feed exactly that many symbols into the bulk consumer. Read moreSource§impl RelativeEncodableKnownLength<Path> for CodecPathExtendsPath
Implements path_extends_path.
impl RelativeEncodableKnownLength<Path> for CodecPathExtendsPath
Implements path_extends_path.
Source§fn len_of_relative_encoding(&self, rel: &Path) -> usize
fn len_of_relative_encoding(&self, rel: &Path) -> usize
self, relative to rel. A successful call to relative_encode must feed exactly that many symbols into the bulk consumer. Read moreimpl SuccessorExceptForGreatest for Path
Source§impl TryPredecessor for Path
impl TryPredecessor for Path
Source§fn try_predecessor(&self) -> Option<Self>
fn try_predecessor(&self) -> Option<Self>
self has a predecessor, i.e., a unique greatest value which is strictly less than self, returns it. If there is no unique predecessor, returns None.Source§fn is_predecessor_of(&self, other: &Self) -> bool
fn is_predecessor_of(&self, other: &Self) -> bool
true iff self is the predecessor of other.Source§fn is_not_predecessor_of(&self, other: &Self) -> bool
fn is_not_predecessor_of(&self, other: &Self) -> bool
true iff self is not the predecessor of other.Source§impl TrySuccessor for Path
impl TrySuccessor for Path
Source§fn try_successor(&self) -> Option<Self>
fn try_successor(&self) -> Option<Self>
Source§fn is_successor_of(&self, other: &Self) -> bool
fn is_successor_of(&self, other: &Self) -> bool
true iff self is the successor of other.Source§fn is_not_successor_of(&self, other: &Self) -> bool
fn is_not_successor_of(&self, other: &Self) -> bool
true iff self is not the successor of other.Source§impl UpperSemilattice for Path
impl UpperSemilattice for Path
Source§fn least_upper_bound(&self, other: &Self) -> Self
fn least_upper_bound(&self, other: &Self) -> Self
self and other, i.e., the unique least element in the type which is greater than or equal to both self and other.Auto Trait Implementations§
impl !Freeze for Path
impl RefUnwindSafe for Path
impl Send for Path
impl Sync for Path
impl Unpin for Path
impl UnsafeUnpin for Path
impl UnwindSafe for Path
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
impl<T> BoundedLattice for Twhere
T: BoundedLowerSemilattice + BoundedUpperSemilattice,
Source§impl<T> BoundedLowerSemilattice for Twhere
T: LowerSemilattice + LeastElement,
impl<T> BoundedLowerSemilattice for Twhere
T: LowerSemilattice + LeastElement,
Source§fn greatest_lower_bound_slice(values: &[Self]) -> Self
fn greatest_lower_bound_slice(values: &[Self]) -> Self
Source§impl<T> BoundedUpperSemilattice for Twhere
T: UpperSemilattice + GreatestElement,
impl<T> BoundedUpperSemilattice for Twhere
T: UpperSemilattice + GreatestElement,
Source§fn least_upper_bound_slice(values: &[Self]) -> Self
fn least_upper_bound_slice(values: &[Self]) -> Self
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<T, S> EncodableExt<S> for Twhere
T: Encodable<S>,
impl<T, S> EncodableExt<S> for Twhere
T: Encodable<S>,
Source§impl<T, S> EncodableKnownLengthExt<S> for Twhere
T: EncodableKnownLength<S>,
impl<T, S> EncodableKnownLengthExt<S> for Twhere
T: EncodableKnownLength<S>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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> ⓘ
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> ⓘ
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 more