relative_path

Struct RelativePathBuf

Source
pub struct RelativePathBuf { /* private fields */ }
Expand description

An owned, mutable relative path.

This type provides methods to manipulate relative path objects.

Implementations§

Source§

impl RelativePathBuf

Source

pub fn new() -> RelativePathBuf

Create a new relative path buffer.

Source

pub fn from_path<P: AsRef<Path>>( path: P, ) -> Result<RelativePathBuf, FromPathError>

Try to convert a Path to a RelativePathBuf.

§Examples
use relative_path::{RelativePath, RelativePathBuf, FromPathErrorKind};
use std::path::Path;

assert_eq!(
    Ok(RelativePath::new("foo/bar").to_owned()),
    RelativePathBuf::from_path(Path::new("foo/bar"))
);
§Errors

This will error in case the provided path is not a relative path, which is identifier by it having a Prefix or RootDir component.

Source

pub fn push<P>(&mut self, path: P)
where P: AsRef<RelativePath>,

Extends self with path.

§Examples
use relative_path::RelativePathBuf;

let mut path = RelativePathBuf::new();
path.push("foo");
path.push("bar");

assert_eq!("foo/bar", path);

let mut path = RelativePathBuf::new();
path.push("foo");
path.push("/bar");

assert_eq!("foo/bar", path);
Source

pub fn set_file_name<S: AsRef<str>>(&mut self, file_name: S)

Updates file_name to file_name.

If file_name was None, this is equivalent to pushing file_name.

Otherwise it is equivalent to calling pop and then pushing file_name. The new path will be a sibling of the original path. (That is, it will have the same parent.)

§Examples
use relative_path::RelativePathBuf;

let mut buf = RelativePathBuf::from("");
assert!(buf.file_name() == None);
buf.set_file_name("bar");
assert_eq!(RelativePathBuf::from("bar"), buf);

assert!(buf.file_name().is_some());
buf.set_file_name("baz.txt");
assert_eq!(RelativePathBuf::from("baz.txt"), buf);

buf.push("bar");
assert!(buf.file_name().is_some());
buf.set_file_name("bar.txt");
assert_eq!(RelativePathBuf::from("baz.txt/bar.txt"), buf);
Source

pub fn set_extension<S: AsRef<str>>(&mut self, extension: S) -> bool

Updates extension to extension.

Returns false and does nothing if file_name is None, returns true and updates the extension otherwise.

If extension is None, the extension is added; otherwise it is replaced.

§Examples
use relative_path::{RelativePath, RelativePathBuf};

let mut p = RelativePathBuf::from("feel/the");

p.set_extension("force");
assert_eq!(RelativePath::new("feel/the.force"), p);

p.set_extension("dark_side");
assert_eq!(RelativePath::new("feel/the.dark_side"), p);

assert!(p.pop());
p.set_extension("nothing");
assert_eq!(RelativePath::new("feel.nothing"), p);
Source

pub fn pop(&mut self) -> bool

Truncates self to parent.

§Examples
use relative_path::{RelativePath, RelativePathBuf};

let mut p = RelativePathBuf::from("test/test.rs");

assert_eq!(true, p.pop());
assert_eq!(RelativePath::new("test"), p);
assert_eq!(true, p.pop());
assert_eq!(RelativePath::new(""), p);
assert_eq!(false, p.pop());
assert_eq!(RelativePath::new(""), p);
Source

pub fn as_relative_path(&self) -> &RelativePath

Coerce to a RelativePath slice.

Source

pub fn into_string(self) -> String

Consumes the RelativePathBuf, yielding its internal String storage.

§Examples
use relative_path::RelativePathBuf;

let p = RelativePathBuf::from("/the/head");
let string = p.into_string();
assert_eq!(string, "/the/head".to_owned());
Source

pub fn into_boxed_relative_path(self) -> Box<RelativePath>

Converts this RelativePathBuf into a boxed RelativePath.

Methods from Deref<Target = RelativePath>§

Source

pub fn as_str(&self) -> &str

Yields the underlying str slice.

§Examples
use relative_path::RelativePath;

assert_eq!(RelativePath::new("foo.txt").as_str(), "foo.txt");
Source

pub fn display(&self) -> Display<'_>

👎Deprecated: RelativePath implements std::fmt::Display directly

Returns an object that implements Display.

§Examples
use relative_path::RelativePath;

let path = RelativePath::new("tmp/foo.rs");

println!("{}", path.display());
Source

pub fn join<P>(&self, path: P) -> RelativePathBuf
where P: AsRef<RelativePath>,

Creates an owned RelativePathBuf with path adjoined to self.

§Examples
use relative_path::RelativePath;

let path = RelativePath::new("foo/bar");
assert_eq!("foo/bar/baz", path.join("baz"));
Source

pub fn components(&self) -> Components<'_>

Iterate over all components in this relative path.

§Examples
use relative_path::{Component, RelativePath};

let path = RelativePath::new("foo/bar/baz");
let mut it = path.components();

assert_eq!(Some(Component::Normal("foo")), it.next());
assert_eq!(Some(Component::Normal("bar")), it.next());
assert_eq!(Some(Component::Normal("baz")), it.next());
assert_eq!(None, it.next());
Source

pub fn iter(&self) -> Iter<'_>

Produces an iterator over the path’s components viewed as str slices.

For more information about the particulars of how the path is separated into components, see components.

§Examples
use relative_path::RelativePath;

let mut it = RelativePath::new("/tmp/foo.txt").iter();
assert_eq!(it.next(), Some("tmp"));
assert_eq!(it.next(), Some("foo.txt"));
assert_eq!(it.next(), None)
Source

pub fn to_relative_path_buf(&self) -> RelativePathBuf

Convert to an owned RelativePathBuf.

Source

pub fn to_path<P: AsRef<Path>>(&self, base: P) -> PathBuf

Build an owned PathBuf relative to base for the current relative path.

§Examples
use relative_path::RelativePath;
use std::path::Path;

let path = RelativePath::new("foo/bar").to_path(".");
assert_eq!(Path::new("./foo/bar"), path);

let path = RelativePath::new("foo/bar").to_path("");
assert_eq!(Path::new("foo/bar"), path);
§Encoding an absolute path

Absolute paths are, in contrast to when using PathBuf::push ignored and will be added unchanged to the buffer.

This is to preserve the probability of a path conversion failing if the relative path contains platform-specific absolute path components.

use relative_path::RelativePath;
use std::path::Path;

if cfg!(windows) {
    let path = RelativePath::new("/bar/baz").to_path("foo");
    assert_eq!(Path::new("foo\\bar\\baz"), path);

    let path = RelativePath::new("c:\\bar\\baz").to_path("foo");
    assert_eq!(Path::new("foo\\c:\\bar\\baz"), path);
}

if cfg!(unix) {
    let path = RelativePath::new("/bar/baz").to_path("foo");
    assert_eq!(Path::new("foo/bar/baz"), path);

    let path = RelativePath::new("c:\\bar\\baz").to_path("foo");
    assert_eq!(Path::new("foo/c:\\bar\\baz"), path);
}
Source

pub fn to_logical_path<P: AsRef<Path>>(&self, base: P) -> PathBuf

Build an owned PathBuf relative to base for the current relative path.

This is similar to to_path except that it doesn’t just unconditionally append one path to the other, instead it performs the following operations depending on its own components:

Note that the exact semantics of the path operation is determined by the corresponding PathBuf operation. E.g. popping a component off a path like . will result in an empty path.

use relative_path::RelativePath;
use std::path::Path;

let path = RelativePath::new("..").to_logical_path(".");
assert_eq!(path, Path::new(""));
§Examples
use relative_path::RelativePath;
use std::path::Path;

let path = RelativePath::new("..").to_logical_path("foo/bar");
assert_eq!(path, Path::new("foo"));
§Encoding an absolute path

Behaves the same as to_path when encoding absolute paths.

Absolute paths are, in contrast to when using PathBuf::push ignored and will be added unchanged to the buffer.

This is to preserve the probability of a path conversion failing if the relative path contains platform-specific absolute path components.

use relative_path::RelativePath;
use std::path::Path;

if cfg!(windows) {
    let path = RelativePath::new("/bar/baz").to_logical_path("foo");
    assert_eq!(Path::new("foo\\bar\\baz"), path);

    let path = RelativePath::new("c:\\bar\\baz").to_logical_path("foo");
    assert_eq!(Path::new("foo\\c:\\bar\\baz"), path);

    let path = RelativePath::new("foo/bar").to_logical_path("");
    assert_eq!(Path::new("foo\\bar"), path);
}

if cfg!(unix) {
    let path = RelativePath::new("/bar/baz").to_logical_path("foo");
    assert_eq!(Path::new("foo/bar/baz"), path);

    let path = RelativePath::new("c:\\bar\\baz").to_logical_path("foo");
    assert_eq!(Path::new("foo/c:\\bar\\baz"), path);

    let path = RelativePath::new("foo/bar").to_logical_path("");
    assert_eq!(Path::new("foo/bar"), path);
}
Source

pub fn parent(&self) -> Option<&RelativePath>

Returns a relative path, without its final Component if there is one.

§Examples
use relative_path::RelativePath;

assert_eq!(Some(RelativePath::new("foo")), RelativePath::new("foo/bar").parent());
assert_eq!(Some(RelativePath::new("")), RelativePath::new("foo").parent());
assert_eq!(None, RelativePath::new("").parent());
Source

pub fn file_name(&self) -> Option<&str>

Returns the final component of the RelativePath, if there is one.

If the path is a normal file, this is the file name. If it’s the path of a directory, this is the directory name.

Returns None If the path terminates in ...

§Examples
use relative_path::RelativePath;

assert_eq!(Some("bin"), RelativePath::new("usr/bin/").file_name());
assert_eq!(Some("foo.txt"), RelativePath::new("tmp/foo.txt").file_name());
assert_eq!(Some("foo.txt"), RelativePath::new("tmp/foo.txt/").file_name());
assert_eq!(Some("foo.txt"), RelativePath::new("foo.txt/.").file_name());
assert_eq!(Some("foo.txt"), RelativePath::new("foo.txt/.//").file_name());
assert_eq!(None, RelativePath::new("foo.txt/..").file_name());
assert_eq!(None, RelativePath::new("/").file_name());
Source

pub fn strip_prefix<P>( &self, base: P, ) -> Result<&RelativePath, StripPrefixError>
where P: AsRef<RelativePath>,

Returns a relative path that, when joined onto base, yields self.

§Errors

If base is not a prefix of self (i.e. starts_with returns false), returns Err.

§Examples
use relative_path::RelativePath;

let path = RelativePath::new("test/haha/foo.txt");

assert_eq!(path.strip_prefix("test"), Ok(RelativePath::new("haha/foo.txt")));
assert_eq!(path.strip_prefix("test").is_ok(), true);
assert_eq!(path.strip_prefix("haha").is_ok(), false);
Source

pub fn starts_with<P>(&self, base: P) -> bool
where P: AsRef<RelativePath>,

Determines whether base is a prefix of self.

Only considers whole path components to match.

§Examples
use relative_path::RelativePath;

let path = RelativePath::new("etc/passwd");

assert!(path.starts_with("etc"));

assert!(!path.starts_with("e"));
Source

pub fn ends_with<P>(&self, child: P) -> bool
where P: AsRef<RelativePath>,

Determines whether child is a suffix of self.

Only considers whole path components to match.

§Examples
use relative_path::RelativePath;

let path = RelativePath::new("etc/passwd");

assert!(path.ends_with("passwd"));
Source

pub fn is_normalized(&self) -> bool

Determines whether self is normalized.

§Examples
use relative_path::RelativePath;

// These are normalized.
assert!(RelativePath::new("").is_normalized());
assert!(RelativePath::new("baz.txt").is_normalized());
assert!(RelativePath::new("foo/bar/baz.txt").is_normalized());
assert!(RelativePath::new("..").is_normalized());
assert!(RelativePath::new("../..").is_normalized());
assert!(RelativePath::new("../../foo/bar/baz.txt").is_normalized());

// These are not normalized.
assert!(!RelativePath::new(".").is_normalized());
assert!(!RelativePath::new("./baz.txt").is_normalized());
assert!(!RelativePath::new("foo/..").is_normalized());
assert!(!RelativePath::new("foo/../baz.txt").is_normalized());
assert!(!RelativePath::new("foo/.").is_normalized());
assert!(!RelativePath::new("foo/./baz.txt").is_normalized());
assert!(!RelativePath::new("../foo/./bar/../baz.txt").is_normalized());
Source

pub fn with_file_name<S: AsRef<str>>(&self, file_name: S) -> RelativePathBuf

Creates an owned RelativePathBuf like self but with the given file name.

See set_file_name for more details.

§Examples
use relative_path::{RelativePath, RelativePathBuf};

let path = RelativePath::new("tmp/foo.txt");
assert_eq!(path.with_file_name("bar.txt"), RelativePathBuf::from("tmp/bar.txt"));

let path = RelativePath::new("tmp");
assert_eq!(path.with_file_name("var"), RelativePathBuf::from("var"));
Source

pub fn file_stem(&self) -> Option<&str>

Extracts the stem (non-extension) portion of file_name.

The stem is:

  • None, if there is no file name;
  • The entire file name if there is no embedded .;
  • The entire file name if the file name begins with . and has no other .s within;
  • Otherwise, the portion of the file name before the final .
§Examples
use relative_path::RelativePath;

let path = RelativePath::new("foo.rs");

assert_eq!("foo", path.file_stem().unwrap());
Source

pub fn extension(&self) -> Option<&str>

Extracts the extension of file_name, if possible.

The extension is:

  • None, if there is no file name;
  • None, if there is no embedded .;
  • None, if the file name begins with . and has no other .s within;
  • Otherwise, the portion of the file name after the final .
§Examples
use relative_path::RelativePath;

assert_eq!(Some("rs"), RelativePath::new("foo.rs").extension());
assert_eq!(None, RelativePath::new(".rs").extension());
assert_eq!(Some("rs"), RelativePath::new("foo.rs/.").extension());
Source

pub fn with_extension<S: AsRef<str>>(&self, extension: S) -> RelativePathBuf

Creates an owned RelativePathBuf like self but with the given extension.

See set_extension for more details.

§Examples
use relative_path::{RelativePath, RelativePathBuf};

let path = RelativePath::new("foo.rs");
assert_eq!(path.with_extension("txt"), RelativePathBuf::from("foo.txt"));
Source

pub fn join_normalized<P>(&self, path: P) -> RelativePathBuf
where P: AsRef<RelativePath>,

Build an owned RelativePathBuf, joined with the given path and normalized.

§Examples
use relative_path::RelativePath;

assert_eq!(
    RelativePath::new("foo/baz.txt"),
    RelativePath::new("foo/bar").join_normalized("../baz.txt").as_relative_path()
);

assert_eq!(
    RelativePath::new("../foo/baz.txt"),
    RelativePath::new("../foo/bar").join_normalized("../baz.txt").as_relative_path()
);
Source

pub fn normalize(&self) -> RelativePathBuf

Return an owned RelativePathBuf, with all non-normal components moved to the beginning of the path.

This permits for a normalized representation of different relative components.

Normalization is a destructive operation if the path references an actual filesystem path. An example of this is symlinks under unix, a path like foo/../bar might reference a different location other than ./bar.

Normalization is a logical operation and does not guarantee that the constructed path corresponds to what the filesystem would do. On Linux for example symbolic links could mean that the logical path doesn’t correspond to the filesystem path.

§Examples
use relative_path::RelativePath;

assert_eq!(
    "../foo/baz.txt",
    RelativePath::new("../foo/./bar/../baz.txt").normalize()
);

assert_eq!(
    "",
    RelativePath::new(".").normalize()
);
Source

pub fn relative<P>(&self, path: P) -> RelativePathBuf
where P: AsRef<RelativePath>,

Constructs a relative path from the current path, to path.

This function will return the empty RelativePath "" if this source contains unnamed components like .. that would have to be traversed to reach the destination path. This is necessary since we have no way of knowing what the names of those components are when we’re building the new relative path.

use relative_path::RelativePath;

// Here we don't know what directories `../..` refers to, so there's no
// way to construct a path back to `bar` in the current directory from
// `../..`.
let from = RelativePath::new("../../foo/relative-path");
let to = RelativePath::new("bar");
assert_eq!("", from.relative(to));

One exception to this is when two paths contains a common prefix at which point there’s no need to know what the names of those unnamed components are.

use relative_path::RelativePath;

let from = RelativePath::new("../../foo/bar");
let to = RelativePath::new("../../foo/baz");

assert_eq!("../baz", from.relative(to));

let from = RelativePath::new("../a/../../foo/bar");
let to = RelativePath::new("../../foo/baz");

assert_eq!("../baz", from.relative(to));
§Examples
use relative_path::RelativePath;

assert_eq!(
    "../../e/f",
    RelativePath::new("a/b/c/d").relative(RelativePath::new("a/b/e/f"))
);

assert_eq!(
    "../bbb",
    RelativePath::new("a/../aaa").relative(RelativePath::new("b/../bbb"))
);

let a = RelativePath::new("git/relative-path");
let b = RelativePath::new("git");
assert_eq!("relative-path", b.relative(a));
assert_eq!("..", a.relative(b));

let a = RelativePath::new("foo/bar/bap/foo.h");
let b = RelativePath::new("../arch/foo.h");
assert_eq!("../../../../../arch/foo.h", a.relative(b));
assert_eq!("", b.relative(a));

Trait Implementations§

Source§

impl AsRef<RelativePath> for RelativePathBuf

Source§

fn as_ref(&self) -> &RelativePath

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<str> for RelativePathBuf

AsRef<str> implementation for RelativePathBuf.

§Examples

use relative_path::RelativePathBuf;

let path = RelativePathBuf::from("foo/bar");
let string: &str = path.as_ref();
assert_eq!(string, "foo/bar");
Source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<RelativePath> for RelativePathBuf

Source§

fn borrow(&self) -> &RelativePath

Immutably borrows from an owned value. Read more
Source§

impl Clone for RelativePathBuf

Source§

fn clone(&self) -> RelativePathBuf

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RelativePathBuf

Source§

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

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

impl Default for RelativePathBuf

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Deref for RelativePathBuf

Source§

type Target = RelativePath

The resulting type after dereferencing.
Source§

fn deref(&self) -> &RelativePath

Dereferences the value.
Source§

impl<'de> Deserialize<'de> for RelativePathBuf

serde::de::Deserialize implementation for RelativePathBuf.

use serde::Deserialize;
use relative_path::RelativePathBuf;

#[derive(Deserialize)]
struct Document {
    path: RelativePathBuf,
}
Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for RelativePathBuf

Source§

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

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

impl<P> Extend<P> for RelativePathBuf
where P: AsRef<RelativePath>,

Source§

fn extend<I: IntoIterator<Item = P>>(&mut self, iter: I)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<'a, T: ?Sized + AsRef<str>> From<&'a T> for RelativePathBuf

Source§

fn from(path: &'a T) -> RelativePathBuf

Converts to this type from the input type.
Source§

impl From<RelativePathBuf> for Arc<RelativePath>

Conversion from RelativePathBuf to Arc<RelativePath>.

§Examples

use std::sync::Arc;
use relative_path::{RelativePath, RelativePathBuf};

let path = RelativePathBuf::from("foo/bar");
let path: Arc<RelativePath> = path.into();
assert_eq!(&*path, "foo/bar");
Source§

fn from(path: RelativePathBuf) -> Arc<RelativePath>

Converts to this type from the input type.
Source§

impl From<RelativePathBuf> for Box<RelativePath>

Conversion from RelativePathBuf to Box<RelativePath>.

§Examples

use std::sync::Arc;
use relative_path::{RelativePath, RelativePathBuf};

let path = RelativePathBuf::from("foo/bar");
let path: Box<RelativePath> = path.into();
assert_eq!(&*path, "foo/bar");
Source§

fn from(path: RelativePathBuf) -> Box<RelativePath>

Converts to this type from the input type.
Source§

impl<'a> From<RelativePathBuf> for Cow<'a, RelativePath>

Source§

fn from(s: RelativePathBuf) -> Cow<'a, RelativePath>

Converts to this type from the input type.
Source§

impl From<RelativePathBuf> for Rc<RelativePath>

Conversion from RelativePathBuf to Rc<RelativePath>.

§Examples

use std::rc::Rc;
use relative_path::{RelativePath, RelativePathBuf};

let path = RelativePathBuf::from("foo/bar");
let path: Rc<RelativePath> = path.into();
assert_eq!(&*path, "foo/bar");
Source§

fn from(path: RelativePathBuf) -> Rc<RelativePath>

Converts to this type from the input type.
Source§

impl From<RelativePathBuf> for String

Source§

fn from(path: RelativePathBuf) -> String

Converts to this type from the input type.
Source§

impl From<String> for RelativePathBuf

Source§

fn from(path: String) -> RelativePathBuf

Converts to this type from the input type.
Source§

impl<P> FromIterator<P> for RelativePathBuf
where P: AsRef<RelativePath>,

Source§

fn from_iter<I: IntoIterator<Item = P>>(iter: I) -> RelativePathBuf

Creates a value from an iterator. Read more
Source§

impl Hash for RelativePathBuf

Source§

fn hash<H: Hasher>(&self, h: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for RelativePathBuf

Source§

fn cmp(&self, other: &RelativePathBuf) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<'a, 'b> PartialEq<&'a RelativePath> for RelativePathBuf

Source§

fn eq(&self, other: &&'a RelativePath) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, 'b> PartialEq<&'a str> for RelativePathBuf

Source§

fn eq(&self, other: &&'a str) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, 'b> PartialEq<Cow<'a, RelativePath>> for RelativePathBuf

Source§

fn eq(&self, other: &Cow<'a, RelativePath>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, 'b> PartialEq<RelativePath> for RelativePathBuf

Source§

fn eq(&self, other: &RelativePath) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, 'b> PartialEq<RelativePathBuf> for &'a RelativePath

Source§

fn eq(&self, other: &RelativePathBuf) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, 'b> PartialEq<RelativePathBuf> for &'a str

Source§

fn eq(&self, other: &RelativePathBuf) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, 'b> PartialEq<RelativePathBuf> for Cow<'a, RelativePath>

Source§

fn eq(&self, other: &RelativePathBuf) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, 'b> PartialEq<RelativePathBuf> for RelativePath

Source§

fn eq(&self, other: &RelativePathBuf) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, 'b> PartialEq<RelativePathBuf> for String

Source§

fn eq(&self, other: &RelativePathBuf) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, 'b> PartialEq<RelativePathBuf> for str

Source§

fn eq(&self, other: &RelativePathBuf) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, 'b> PartialEq<String> for RelativePathBuf

Source§

fn eq(&self, other: &String) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, 'b> PartialEq<str> for RelativePathBuf

Source§

fn eq(&self, other: &str) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for RelativePathBuf

Source§

fn eq(&self, other: &RelativePathBuf) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, 'b> PartialOrd<&'a RelativePath> for RelativePathBuf

Source§

fn partial_cmp(&self, other: &&'a RelativePath) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a, 'b> PartialOrd<&'a str> for RelativePathBuf

Source§

fn partial_cmp(&self, other: &&'a str) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a, 'b> PartialOrd<Cow<'a, RelativePath>> for RelativePathBuf

Source§

fn partial_cmp(&self, other: &Cow<'a, RelativePath>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a, 'b> PartialOrd<RelativePath> for RelativePathBuf

Source§

fn partial_cmp(&self, other: &RelativePath) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a, 'b> PartialOrd<RelativePathBuf> for &'a RelativePath

Source§

fn partial_cmp(&self, other: &RelativePathBuf) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a, 'b> PartialOrd<RelativePathBuf> for &'a str

Source§

fn partial_cmp(&self, other: &RelativePathBuf) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a, 'b> PartialOrd<RelativePathBuf> for Cow<'a, RelativePath>

Source§

fn partial_cmp(&self, other: &RelativePathBuf) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a, 'b> PartialOrd<RelativePathBuf> for RelativePath

Source§

fn partial_cmp(&self, other: &RelativePathBuf) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a, 'b> PartialOrd<RelativePathBuf> for String

Source§

fn partial_cmp(&self, other: &RelativePathBuf) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a, 'b> PartialOrd<RelativePathBuf> for str

Source§

fn partial_cmp(&self, other: &RelativePathBuf) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a, 'b> PartialOrd<String> for RelativePathBuf

Source§

fn partial_cmp(&self, other: &String) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a, 'b> PartialOrd<str> for RelativePathBuf

Source§

fn partial_cmp(&self, other: &str) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd for RelativePathBuf

Source§

fn partial_cmp(&self, other: &RelativePathBuf) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for RelativePathBuf

serde::ser::Serialize implementation for RelativePathBuf.

use serde::Serialize;
use relative_path::RelativePathBuf;

#[derive(Serialize)]
struct Document {
    path: RelativePathBuf,
}
Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for RelativePathBuf

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,