Various minor/cosmetic improvements to code
This commit is contained in:
@@ -109,11 +109,11 @@ use sys::path::{is_sep_byte, is_verbatim_sep, MAIN_SEP_STR, parse_prefix};
|
||||
// Windows Prefixes
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// Windows path prefixes, e.g. `C:` or `\\server\share`.
|
||||
/// Windows path prefixes, e.g., `C:` or `\\server\share`.
|
||||
///
|
||||
/// Windows uses a variety of path prefix styles, including references to drive
|
||||
/// volumes (like `C:`), network shared folders (like `\\server\share`), and
|
||||
/// others. In addition, some path prefixes are "verbatim" (i.e. prefixed with
|
||||
/// others. In addition, some path prefixes are "verbatim" (i.e., prefixed with
|
||||
/// `\\?\`), in which case `/` is *not* treated as a separator and essentially
|
||||
/// no normalization is performed.
|
||||
///
|
||||
@@ -148,7 +148,7 @@ use sys::path::{is_sep_byte, is_verbatim_sep, MAIN_SEP_STR, parse_prefix};
|
||||
#[derive(Copy, Clone, Debug, Hash, PartialOrd, Ord, PartialEq, Eq)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub enum Prefix<'a> {
|
||||
/// Verbatim prefix, e.g. `\\?\cat_pics`.
|
||||
/// Verbatim prefix, e.g., `\\?\cat_pics`.
|
||||
///
|
||||
/// Verbatim prefixes consist of `\\?\` immediately followed by the given
|
||||
/// component.
|
||||
@@ -156,7 +156,7 @@ pub enum Prefix<'a> {
|
||||
Verbatim(#[stable(feature = "rust1", since = "1.0.0")] &'a OsStr),
|
||||
|
||||
/// Verbatim prefix using Windows' _**U**niform **N**aming **C**onvention_,
|
||||
/// e.g. `\\?\UNC\server\share`.
|
||||
/// e.g., `\\?\UNC\server\share`.
|
||||
///
|
||||
/// Verbatim UNC prefixes consist of `\\?\UNC\` immediately followed by the
|
||||
/// server's hostname and a share name.
|
||||
@@ -166,14 +166,14 @@ pub enum Prefix<'a> {
|
||||
#[stable(feature = "rust1", since = "1.0.0")] &'a OsStr,
|
||||
),
|
||||
|
||||
/// Verbatim disk prefix, e.g. `\\?\C:\`.
|
||||
/// Verbatim disk prefix, e.g., `\\?\C:\`.
|
||||
///
|
||||
/// Verbatim disk prefixes consist of `\\?\` immediately followed by the
|
||||
/// drive letter and `:\`.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
VerbatimDisk(#[stable(feature = "rust1", since = "1.0.0")] u8),
|
||||
|
||||
/// Device namespace prefix, e.g. `\\.\COM42`.
|
||||
/// Device namespace prefix, e.g., `\\.\COM42`.
|
||||
///
|
||||
/// Device namespace prefixes consist of `\\.\` immediately followed by the
|
||||
/// device name.
|
||||
@@ -227,7 +227,7 @@ impl<'a> Prefix<'a> {
|
||||
|
||||
}
|
||||
|
||||
/// Determines if the prefix is verbatim, i.e. begins with `\\?\`.
|
||||
/// Determines if the prefix is verbatim, i.e., begins with `\\?\`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
@@ -509,7 +509,7 @@ impl<'a> Hash for PrefixComponent<'a> {
|
||||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub enum Component<'a> {
|
||||
/// A Windows path prefix, e.g. `C:` or `\\server\share`.
|
||||
/// A Windows path prefix, e.g., `C:` or `\\server\share`.
|
||||
///
|
||||
/// There is a large variety of prefix types, see [`Prefix`]'s documentation
|
||||
/// for more.
|
||||
@@ -528,15 +528,15 @@ pub enum Component<'a> {
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
RootDir,
|
||||
|
||||
/// A reference to the current directory, i.e. `.`.
|
||||
/// A reference to the current directory, i.e., `.`.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
CurDir,
|
||||
|
||||
/// A reference to the parent directory, i.e. `..`.
|
||||
/// A reference to the parent directory, i.e., `..`.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
ParentDir,
|
||||
|
||||
/// A normal component, e.g. `a` and `b` in `a/b`.
|
||||
/// A normal component, e.g., `a` and `b` in `a/b`.
|
||||
///
|
||||
/// This variant is the most common one, it represents references to files
|
||||
/// or directories.
|
||||
@@ -615,7 +615,7 @@ pub struct Components<'a> {
|
||||
|
||||
// true if path *physically* has a root separator; for most Windows
|
||||
// prefixes, it may have a "logical" rootseparator for the purposes of
|
||||
// normalization, e.g. \\server\share == \\server\share\.
|
||||
// normalization, e.g., \\server\share == \\server\share\.
|
||||
has_physical_root: bool,
|
||||
|
||||
// The iterator is double-ended, and these two states keep track of what has
|
||||
@@ -798,7 +798,7 @@ impl<'a> Components<'a> {
|
||||
(comp.len() + extra, self.parse_single_component(comp))
|
||||
}
|
||||
|
||||
// trim away repeated separators (i.e. empty components) on the left
|
||||
// trim away repeated separators (i.e., empty components) on the left
|
||||
fn trim_left(&mut self) {
|
||||
while !self.path.is_empty() {
|
||||
let (size, comp) = self.parse_next_component();
|
||||
@@ -810,7 +810,7 @@ impl<'a> Components<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
// trim away repeated separators (i.e. empty components) on the right
|
||||
// trim away repeated separators (i.e., empty components) on the right
|
||||
fn trim_right(&mut self) {
|
||||
while self.path.len() > self.len_before_body() {
|
||||
let (size, comp) = self.parse_next_component_back();
|
||||
@@ -1178,7 +1178,7 @@ impl PathBuf {
|
||||
///
|
||||
/// On Windows:
|
||||
///
|
||||
/// * if `path` has a root but no prefix (e.g. `\windows`), it
|
||||
/// * if `path` has a root but no prefix (e.g., `\windows`), it
|
||||
/// replaces everything except for the prefix (if any) of `self`.
|
||||
/// * if `path` has a prefix but no root, it replaces `self`.
|
||||
///
|
||||
@@ -1225,7 +1225,7 @@ impl PathBuf {
|
||||
if path.is_absolute() || path.prefix().is_some() {
|
||||
self.as_mut_vec().truncate(0);
|
||||
|
||||
// `path` has a root but no prefix, e.g. `\windows` (Windows only)
|
||||
// `path` has a root but no prefix, e.g., `\windows` (Windows only)
|
||||
} else if path.has_root() {
|
||||
let prefix_len = self.components().prefix_remaining();
|
||||
self.as_mut_vec().truncate(prefix_len);
|
||||
@@ -1810,7 +1810,7 @@ impl Path {
|
||||
PathBuf::from(self.inner.to_os_string())
|
||||
}
|
||||
|
||||
/// Returns `true` if the `Path` is absolute, i.e. if it is independent of
|
||||
/// Returns `true` if the `Path` is absolute, i.e., if it is independent of
|
||||
/// the current directory.
|
||||
///
|
||||
/// * On Unix, a path is absolute if it starts with the root, so
|
||||
@@ -1839,7 +1839,7 @@ impl Path {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns `true` if the `Path` is relative, i.e. not absolute.
|
||||
/// Returns `true` if the `Path` is relative, i.e., not absolute.
|
||||
///
|
||||
/// See [`is_absolute`]'s documentation for more details.
|
||||
///
|
||||
@@ -1866,9 +1866,9 @@ impl Path {
|
||||
/// * On Unix, a path has a root if it begins with `/`.
|
||||
///
|
||||
/// * On Windows, a path has a root if it:
|
||||
/// * has no prefix and begins with a separator, e.g. `\windows`
|
||||
/// * has a prefix followed by a separator, e.g. `c:\windows` but not `c:windows`
|
||||
/// * has any non-disk prefix, e.g. `\\server\share`
|
||||
/// * has no prefix and begins with a separator, e.g., `\windows`
|
||||
/// * has a prefix followed by a separator, e.g., `c:\windows` but not `c:windows`
|
||||
/// * has any non-disk prefix, e.g., `\\server\share`
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
@@ -1980,7 +1980,7 @@ impl Path {
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// If `base` is not a prefix of `self` (i.e. [`starts_with`]
|
||||
/// If `base` is not a prefix of `self` (i.e., [`starts_with`]
|
||||
/// returns `false`), returns [`Err`].
|
||||
///
|
||||
/// [`starts_with`]: #method.starts_with
|
||||
@@ -2406,7 +2406,7 @@ impl Path {
|
||||
/// This function will traverse symbolic links to query information about the
|
||||
/// destination file. In case of broken symbolic links this will return `false`.
|
||||
///
|
||||
/// If you cannot access the directory containing the file, e.g. because of a
|
||||
/// If you cannot access the directory containing the file, e.g., because of a
|
||||
/// permission error, this will return `false`.
|
||||
///
|
||||
/// # Examples
|
||||
@@ -2432,7 +2432,7 @@ impl Path {
|
||||
/// This function will traverse symbolic links to query information about the
|
||||
/// destination file. In case of broken symbolic links this will return `false`.
|
||||
///
|
||||
/// If you cannot access the directory containing the file, e.g. because of a
|
||||
/// If you cannot access the directory containing the file, e.g., because of a
|
||||
/// permission error, this will return `false`.
|
||||
///
|
||||
/// # Examples
|
||||
@@ -2461,7 +2461,7 @@ impl Path {
|
||||
/// This function will traverse symbolic links to query information about the
|
||||
/// destination file. In case of broken symbolic links this will return `false`.
|
||||
///
|
||||
/// If you cannot access the directory containing the file, e.g. because of a
|
||||
/// If you cannot access the directory containing the file, e.g., because of a
|
||||
/// permission error, this will return `false`.
|
||||
///
|
||||
/// # Examples
|
||||
|
||||
Reference in New Issue
Block a user