File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -250,6 +250,26 @@ impl Path {
250
250
self . inner . file_stem ( )
251
251
}
252
252
253
+ /// Returns `true` if the `Path` has a root.
254
+ ///
255
+ /// * On Unix, a path has a root if it begins with `/`.
256
+ ///
257
+ /// * On Windows, a path has a root if it:
258
+ /// * has no prefix and begins with a separator, e.g., `\windows`
259
+ /// * has a prefix followed by a separator, e.g., `c:\windows` but not `c:windows`
260
+ /// * has any non-disk prefix, e.g., `\\server\share`
261
+ ///
262
+ /// # Examples
263
+ ///
264
+ /// ```
265
+ /// use async_std::path::Path;
266
+ ///
267
+ /// assert!(Path::new("/etc/passwd").has_root());
268
+ /// ```
269
+ pub fn has_root ( & self ) -> bool {
270
+ self . inner . has_root ( )
271
+ }
272
+
253
273
/// Converts a [`Box<Path>`][`Box`] into a [`PathBuf`] without copying or
254
274
/// allocating.
255
275
///
You can’t perform that action at this time.
0 commit comments