pub struct SpecialNotFilePath<'a>(/* private fields */);Expand description
A SchemeType::SpecialNotFile path.
Implementations§
Source§impl SpecialNotFilePath<'_>
impl SpecialNotFilePath<'_>
Sourcepub fn iter_strs(&self) -> SplitSlashes<'_> ⓘ
pub fn iter_strs(&self) -> SplitSlashes<'_> ⓘ
The segments as strs.
Sourcepub fn range_str<B: RangeBounds<isize>>(&self, range: B) -> Option<&str>
pub fn range_str<B: RangeBounds<isize>>(&self, range: B) -> Option<&str>
The range of segments as a str.
Sourcepub fn iter(&self) -> SpecialNotFilePathSegmentsIter<'_> ⓘ
pub fn iter(&self) -> SpecialNotFilePathSegmentsIter<'_> ⓘ
Sourcepub fn get(&self, index: isize) -> Option<SpecialNotFilePathSegment<'_>>
pub fn get(&self, index: isize) -> Option<SpecialNotFilePathSegment<'_>>
The indexth SpecialNotFilePathSegment.
Sourcepub fn range<B: RangeBounds<isize>>(
&self,
range: B,
) -> Option<SpecialNotFilePathSegments<'_>>
pub fn range<B: RangeBounds<isize>>( &self, range: B, ) -> Option<SpecialNotFilePathSegments<'_>>
The range of SpecialNotFilePathSegments.
§Examples
use better_url::prelude::*;
let path = SpecialNotFilePath::new("/ab/cd/ef");
assert_eq!(path.range(0.. 2).unwrap(), "ab/cd");
assert_eq!(path.range(0.. -1).unwrap(), "ab/cd");
assert_eq!(path.range(0..= 2).unwrap(), "ab/cd/ef");
assert_eq!(path.range(0..=-1).unwrap(), "ab/cd/ef");Source§impl SpecialNotFilePath<'_>
impl SpecialNotFilePath<'_>
Sourcepub fn push<'a, T: Into<SpecialNotFilePathSegment<'a>>>(
&mut self,
value: T,
) -> bool
pub fn push<'a, T: Into<SpecialNotFilePathSegment<'a>>>( &mut self, value: T, ) -> bool
Append value.
§Examples
use better_url::prelude::*;
let mut path = SpecialNotFilePath::new("/abc/def/ghi");
path.push("123"); assert_eq!(path, "/abc/def/ghi/123");
path.push(".." ); assert_eq!(path, "/abc/def/ghi/" );
path.push(".." ); assert_eq!(path, "/abc/def/ghi/" );
path.push("." ); assert_eq!(path, "/abc/def/ghi//" );Sourcepub fn prepend<'a, T: Into<SpecialNotFilePathSegment<'a>>>(
&mut self,
value: T,
) -> bool
pub fn prepend<'a, T: Into<SpecialNotFilePathSegment<'a>>>( &mut self, value: T, ) -> bool
Prepend value.
§Examples
use better_url::prelude::*;
let mut path = SpecialNotFilePath::new("/abc/def/ghi");
path.prepend("123"); assert_eq!(path, "/123/abc/def/ghi");
path.prepend("." ); assert_eq!(path, "/123/abc/def/ghi");
path.prepend(".." ); assert_eq!(path, "/123/abc/def/ghi");Sourcepub fn set<'a, T: Into<SpecialNotFilePathSegment<'a>>>(
&mut self,
index: isize,
value: Option<T>,
) -> Result<bool, SetPathError>
pub fn set<'a, T: Into<SpecialNotFilePathSegment<'a>>>( &mut self, index: isize, value: Option<T>, ) -> Result<bool, SetPathError>
Set, insert, or remove the indexth segment.
If value is None and index is out of bounds, does nothing.
§Errors
If value is Some and index is more than 1 out of bounds, returns the error InsertNotFound.
If value is None and index is the only segment, returns the error CantBeEmpty.
§Examples
use better_url::prelude::*;
let mut path = SpecialNotFilePath::new("/abc/def/ghi");
path.set(1, Some("123" )).unwrap(); assert_eq!(path, "/abc/123/ghi");
path.set(2, Some(".." )).unwrap(); assert_eq!(path, "/abc/" );
path.set(1, None::<&str> ).unwrap(); assert_eq!(path, "/abc" );Sourcepub fn set_range<'a, T: Into<SpecialNotFilePathSegments<'a>>, B: RangeBounds<isize>>(
&mut self,
range: B,
value: Option<T>,
) -> Result<bool, SetPathError>
pub fn set_range<'a, T: Into<SpecialNotFilePathSegments<'a>>, B: RangeBounds<isize>>( &mut self, range: B, value: Option<T>, ) -> Result<bool, SetPathError>
Set the range of segments.
§Errors
If Self::range_str returns None, returns the error RangeNotFound.
§Examples
use better_url::prelude::*;
let mut path = SpecialNotFilePath::new("/c:/abc/def/ghi");
path.set_range(1..2, Some(".././123/.")).unwrap(); assert_eq!(path, "/123/def/ghi");Sourcepub fn insert<'a, T: Into<SpecialNotFilePathSegment<'a>>>(
&mut self,
index: isize,
value: T,
) -> Result<bool, SetPathError>
pub fn insert<'a, T: Into<SpecialNotFilePathSegment<'a>>>( &mut self, index: isize, value: T, ) -> Result<bool, SetPathError>
Insert a new indexth segment.
§Errors
If the insert isn’t found, returns the error InsertNotFound.
§Examples
use better_url::prelude::*;
let mut path = SpecialNotFilePath::new("/abc/def/ghi");
path.insert( 1, "123").unwrap(); assert_eq!(path, "/abc/123/def/ghi");
path.insert( 2, ".." ).unwrap(); assert_eq!(path, "/abc/def/ghi" );
path.insert(-1, "123").unwrap(); assert_eq!(path, "/abc/def/ghi/123");Source§impl SpecialNotFilePath<'_>
impl SpecialNotFilePath<'_>
Sourcepub fn pop(&mut self) -> Result<bool, SetPathError>
pub fn pop(&mut self) -> Result<bool, SetPathError>
Remove the last segment if it exists.
§Errors
If there’s only one segment, returns the error CantBeEmpty.
Sourcepub fn pop_if_empty(&mut self) -> Result<bool, SetPathError>
pub fn pop_if_empty(&mut self) -> Result<bool, SetPathError>
Remove the last segment if it exists and is empty.
§Errors
If there is only one segment and it’s empty, returns the error CantBeNone.
Sourcepub fn remove(&mut self, index: isize) -> Result<bool, SetPathError>
pub fn remove(&mut self, index: isize) -> Result<bool, SetPathError>
Remove the indexth segment if it exists.
§Errors
If there is only one segment, returns the error CantBeEmpty.
Source§impl<'a> SpecialNotFilePath<'a>
impl<'a> SpecialNotFilePath<'a>
Sourcepub unsafe fn new_unchecked<T: Into<Cow<'a, str>>>(value: T) -> Self
pub unsafe fn new_unchecked<T: Into<Cow<'a, str>>>(value: T) -> Self
Sourcepub fn segments(&self) -> SpecialNotFilePathSegments<'_>
pub fn segments(&self) -> SpecialNotFilePathSegments<'_>
Sourcepub fn into_inner(self) -> Cow<'a, str>
pub fn into_inner(self) -> Cow<'a, str>
Turn into the inner Cow.
Sourcepub fn into_owned(self) -> SpecialNotFilePath<'static>
pub fn into_owned(self) -> SpecialNotFilePath<'static>
Turn into an owned Self.
Sourcepub fn borrowed(&self) -> SpecialNotFilePath<'_>
pub fn borrowed(&self) -> SpecialNotFilePath<'_>
Make a borrowing Self.