Struct fluent_uri::Path
source · #[repr(transparent)]pub struct Path { /* private fields */ }
Expand description
The path component of URI reference.
Implementations§
source§impl Path
impl Path
sourcepub fn is_absolute(&self) -> bool
pub fn is_absolute(&self) -> bool
Returns true
if the path is absolute, i.e., beginning with “/”.
sourcepub fn is_rootless(&self) -> bool
pub fn is_rootless(&self) -> bool
Returns true
if the path is rootless, i.e., not beginning with “/”.
sourcepub fn segments(&self) -> Split<'_> ⓘ
pub fn segments(&self) -> Split<'_> ⓘ
Returns an iterator over the path segments.
Examples
use fluent_uri::Uri;
// An empty path has no segments.
let uri = Uri::parse("")?;
assert_eq!(uri.path().segments().next(), None);
let uri = Uri::parse("a/b/c")?;
assert!(uri.path().segments().eq(["a", "b", "c"]));
// The empty string before a preceding "/" is not a segment.
// However, segments can be empty in the other cases.
let uri = Uri::parse("/path/to//dir/")?;
assert!(uri.path().segments().eq(["path", "to", "", "dir", ""]));