Struct fluent_uri::Path

source ·
#[repr(transparent)]
pub struct Path { /* private fields */ }
Expand description

The path component of URI reference.

Implementations§

source§

impl Path

source

pub fn as_estr(&self) -> &EStr

Yields the underlying EStr.

source

pub fn as_str(&self) -> &str

Returns the path as a string slice.

source

pub fn is_absolute(&self) -> bool

Returns true if the path is absolute, i.e., beginning with “/”.

source

pub fn is_rootless(&self) -> bool

Returns true if the path is rootless, i.e., not beginning with “/”.

source

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", ""]));

Trait Implementations§

source§

impl Debug for Path

source§

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

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

impl Display for Path

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Path

§

impl Send for Path

§

impl !Sized for Path

§

impl Sync for Path

§

impl Unpin for Path

§

impl UnwindSafe for Path

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

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

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more