Struct normpath::BasePathBuf [−][src]
pub struct BasePathBuf(_);
Expand description
An owned BasePath
.
Implementations
Equivalent to BasePath::new
but returns an owned path.
Examples
use std::path::Path;
use normpath::BasePathBuf;
if cfg!(windows) {
let path = r"X:\foo\bar";
assert_eq!(Path::new(path), BasePathBuf::new(path)?);
assert!(BasePathBuf::new(r"foo\bar").is_ok());
}
Equivalent to BasePath::try_new
but returns an owned path.
Examples
use std::path::Path;
use normpath::BasePathBuf;
if cfg!(windows) {
let path = r"X:\foo\bar";
assert_eq!(Path::new(path), BasePathBuf::try_new(path)?);
assert!(BasePathBuf::try_new(r"foo\bar").is_err());
}
Returns the wrapped path as a platform string.
Returns the wrapped path.
Equivalent to BasePath::parent
but modifies self
in place.
Returns Ok(false)
when BasePath::parent
returns Ok(None)
.
Examples
use std::path::Path;
use normpath::BasePathBuf;
if cfg!(windows) {
let mut path = BasePathBuf::try_new(r"X:\foo\bar").unwrap();
assert!(path.pop()?);
assert_eq!(Path::new(r"X:\foo"), path);
}
Equivalent to PathBuf::pop
.
It is usually better to use pop
.
Examples
use std::path::Path;
use normpath::BasePathBuf;
if cfg!(windows) {
let mut path = BasePathBuf::try_new(r"X:\foo\..").unwrap();
assert!(path.pop_unchecked());
assert_eq!(Path::new(r"X:\foo"), path);
}
Equivalent to BasePath::join
but modifies self
in place.
Examples
use std::path::Path;
use normpath::BasePathBuf;
if cfg!(windows) {
let mut path = BasePathBuf::try_new(r"\\?\foo\bar").unwrap();
path.push("../baz/test.rs");
assert_eq!(Path::new(r"\\?\foo\baz\test.rs"), path);
}
Methods from Deref<Target = BasePath>
Equivalent to Path::canonicalize
.
Equivalent to Path::components
.
Equivalent to Path::ends_with
.
Equivalent to Path::exists
.
Equivalent to Path::extension
.
Equivalent to Path::file_name
.
Equivalent to Path::file_stem
.
Equivalent to Path::has_root
.
Equivalent to Path::is_absolute
.
Equivalent to Path::is_dir
.
Equivalent to Path::is_file
.
Equivalent to Path::is_relative
.
An improved version of Path::join
that handles more edge cases.
For example, on Windows, leading .
and ..
components of path
will
be normalized if possible. If self
is a verbatim path, it would be
invalid to normalize them later.
You should still call normalize
before parent
to normalize some
additional components.
Examples
use std::path::Path;
use normpath::BasePath;
if cfg!(windows) {
assert_eq!(
Path::new(r"\\?\foo\baz\test.rs"),
BasePath::try_new(r"\\?\foo\bar")
.unwrap()
.join("../baz/test.rs"),
);
}
Equivalent to Path::metadata
.
Equivalent to PathExt::normalize
.
This is supported on Windows only.
Equivalent to PathExt::normalize_virtually
.
Returns this path without its last component.
Returns Ok(None)
if the last component is Component::RootDir
.
You should usually only call this method on normalized paths. They
will prevent an unexpected path from being returned due to symlinks,
and some .
and ..
components will be normalized.
Errors
Returns an error if the last component is not Component::Normal
or
Component::RootDir
. To ignore this error, use parent_unchecked
.
Examples
use std::path::Path;
use normpath::BasePath;
if cfg!(windows) {
assert_eq!(
Path::new(r"X:\foo"),
BasePath::try_new(r"X:\foo\bar").unwrap().parent()?.unwrap(),
);
}
Equivalent to Path::parent
.
It is usually better to use parent
.
Examples
use std::path::Path;
use normpath::BasePath;
if cfg!(windows) {
assert_eq!(
Path::new(r"X:\foo"),
BasePath::try_new(r"X:\foo\..")
.unwrap()
.parent_unchecked()
.unwrap(),
);
}
Equivalent to Path::read_dir
.
Equivalent to Path::read_link
.
Equivalent to Path::starts_with
.
Equivalent to Path::symlink_metadata
.
Trait Implementations
Performs the conversion.
Performs the conversion.
Performs the conversion.
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Auto Trait Implementations
impl RefUnwindSafe for BasePathBuf
impl Send for BasePathBuf
impl Sync for BasePathBuf
impl Unpin for BasePathBuf
impl UnwindSafe for BasePathBuf
Blanket Implementations
Mutably borrows from an owned value. Read more