mirror of
https://github.com/async-rs/async-std.git
synced 2025-02-06 20:55:33 +00:00
Implemented Path::has_root
This commit is contained in:
parent
28e936f6fe
commit
3a9597cd32
1 changed files with 20 additions and 0 deletions
|
@ -250,6 +250,26 @@ impl Path {
|
|||
self.inner.file_stem()
|
||||
}
|
||||
|
||||
/// Returns `true` if the `Path` has a root.
|
||||
///
|
||||
/// * 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`
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use async_std::path::Path;
|
||||
///
|
||||
/// assert!(Path::new("/etc/passwd").has_root());
|
||||
/// ```
|
||||
pub fn has_root(&self) -> bool {
|
||||
self.inner.has_root()
|
||||
}
|
||||
|
||||
/// Converts a [`Box<Path>`][`Box`] into a [`PathBuf`] without copying or
|
||||
/// allocating.
|
||||
///
|
||||
|
|
Loading…
Reference in a new issue