pub trait Utf8Component<'a>: AsRef<str> + Clone + Debug + PartialEq + Eq + PartialOrd + Ord + Sealed {
    // Required methods
    fn as_str(&self) -> &'a str;
    fn is_root(&self) -> bool;
    fn is_normal(&self) -> bool;
    fn len(&self) -> usize;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

Interface representing a component in a Utf8Path

Required Methods§

source

fn as_str(&self) -> &'a str

Extracts the underlying str slice

source

fn is_root(&self) -> bool

Returns true if this component is the root component, meaning there are no more components before this one

Use cases are for the root dir separator on Windows and Unix as well as Windows std::path::PrefixComponent

Examples

/my/../path/./here.txt has the components on Unix of

  • UnixComponent::RootDir - is_root() == true
  • UnixComponent::ParentDir - is_root() == false
  • UnixComponent::CurDir - is_root() == false
  • UnixComponent::Normal("here.txt") - is_root() == false
source

fn is_normal(&self) -> bool

Returns true if this component represents a normal part of the path

Examples

/my/../path/./here.txt has the components on Unix of

  • UnixComponent::RootDir - is_normal() == false
  • UnixComponent::ParentDir - is_normal() == false
  • UnixComponent::CurDir - is_normal() == false
  • UnixComponent::Normal("here.txt") - is_normal() == true
source

fn len(&self) -> usize

Returns size of component in bytes

Provided Methods§

source

fn is_empty(&self) -> bool

Returns true if component represents an empty str

Implementors§