File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -281,6 +281,28 @@ impl Path {
281
281
inner. into_path_buf ( ) . into ( )
282
282
}
283
283
284
+ /// Returns `true` if the `Path` is absolute, i.e., if it is independent of
285
+ /// the current directory.
286
+ ///
287
+ /// * On Unix, a path is absolute if it starts with the root, so
288
+ /// `is_absolute` and [`has_root`] are equivalent.
289
+ ///
290
+ /// * On Windows, a path is absolute if it has a prefix and starts with the
291
+ /// root: `c:\windows` is absolute, while `c:temp` and `\temp` are not.
292
+ ///
293
+ /// # Examples
294
+ ///
295
+ /// ```
296
+ /// use async_std::path::Path;
297
+ ///
298
+ /// assert!(!Path::new("foo.txt").is_absolute());
299
+ /// ```
300
+ ///
301
+ /// [`has_root`]: #method.has_root
302
+ pub fn is_absolute ( & self ) -> bool {
303
+ self . inner . is_absolute ( )
304
+ }
305
+
284
306
/// Queries the file system to get information about a file, directory, etc.
285
307
///
286
308
/// This function will traverse symbolic links to query information about the
You can’t perform that action at this time.
0 commit comments