Struct normpath::BasePath [−][src]
#[repr(transparent)]pub struct BasePath(_);
Expand description
A path that has a prefix on Windows.
Note that comparison traits such as PartialEq
will compare paths
literally instead of comparing components. The former is more efficient and
easier to use correctly.
Safety
This type should not be used for memory safety, but implementations can
panic if this path is missing a prefix on Windows. A safe new_unchecked
method might be added later that can safely create invalid base paths.
Although this type is annotated with #[repr(transparent)]
, the inner
representation is not stable. Transmuting between this type and any other
causes immediate undefined behavior.
Implementations
Creates a new base path.
On Windows, if path
is missing a prefix, it will be joined to the
current directory.
Errors
Returns an error if reading the current directory fails.
Examples
use std::path::Path;
use normpath::BasePath;
if cfg!(windows) {
let path = Path::new(r"X:\foo\bar");
assert_eq!(path, *BasePath::new(path)?);
assert!(BasePath::new(Path::new(r"foo\bar")).is_ok());
}
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
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
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
type Owned = BasePathBuf
type Owned = BasePathBuf
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more