Struct PathSegmentsMut
struct PathSegmentsMut<'a> { ... }
Exposes methods to manipulate the path of an URL that is not cannot-be-base.
The path always starts with a / slash, and is made of slash-separated segments.
There is always at least one segment (which may be the empty string).
Examples:
use Url;
#
# use Error;
#
# use Error;
#
# run.unwrap;
Implementations
impl<'a> PathSegmentsMut<'a>
fn clear(self: &mut Self) -> &mut SelfRemove all segments in the path, leaving the minimal
url.path() == "/".Returns
&mut Selfso that method calls can be chained.Example:
use Url; # # use Error; # # use Error; # # run.unwrap;fn pop_if_empty(self: &mut Self) -> &mut SelfRemove the last segment of this URL’s path if it is empty, except if these was only one segment to begin with.
In other words, remove one path trailing slash, if any, unless it is also the initial slash (so this does nothing if
url.path() == "/").Returns
&mut Selfso that method calls can be chained.Example:
use Url; # # use Error; # # use Error; # # run.unwrap;fn pop(self: &mut Self) -> &mut SelfRemove the last segment of this URL’s path.
If the path only has one segment, make it empty such that
url.path() == "/".Returns
&mut Selfso that method calls can be chained.fn push(self: &mut Self, segment: &str) -> &mut SelfAppend the given segment at the end of this URL’s path.
See the documentation for
.extend().Returns
&mut Selfso that method calls can be chained.fn extend<I>(self: &mut Self, segments: I) -> &mut Self where I: IntoIterator, <I as >::Item: AsRef<str>Append each segment from the given iterator at the end of this URL’s path.
Each segment is percent-encoded like in
Url::parseorUrl::join, except that%and/characters are also encoded (to%25and%2F). This is unlikeUrl::parsewhere%is left as-is in case some of the input is already percent-encoded, and/denotes a path segment separator.)Note that, in addition to slashes between new segments, this always adds a slash between the existing path and the new segments except if the existing path is
"/". If the previous last segment was empty (if the path had a trailing slash) the path after.extend()will contain two consecutive slashes. If that is undesired, call.pop_if_empty()first.To obtain a behavior similar to
Url::join, call.pop()unconditionally first.Returns
&mut Selfso that method calls can be chained.Example:
use Url; # # use Error; # # use Error; # # run.unwrap;In order to make sure that parsing the serialization of an URL gives the same URL, a segment is ignored if it is
"."or"..":use Url; # # use Error; # # use Error; # # run.unwrap;
impl<'a> Debug for PathSegmentsMut<'a>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl<'a> Drop for PathSegmentsMut<'a>
fn drop(self: &mut Self)
impl<'a> Freeze for PathSegmentsMut<'a>
impl<'a> RefUnwindSafe for PathSegmentsMut<'a>
impl<'a> Send for PathSegmentsMut<'a>
impl<'a> Sync for PathSegmentsMut<'a>
impl<'a> Unpin for PathSegmentsMut<'a>
impl<'a> UnsafeUnpin for PathSegmentsMut<'a>
impl<'a> UnwindSafe for PathSegmentsMut<'a>
impl<T> Any for PathSegmentsMut<'a>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for PathSegmentsMut<'a>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for PathSegmentsMut<'a>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> ErasedDestructor for PathSegmentsMut<'a>
impl<T> From for PathSegmentsMut<'a>
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into for PathSegmentsMut<'a>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for PathSegmentsMut<'a>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for PathSegmentsMut<'a>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>