From 50be0d264f49cad62088cd08cee1e80de6efa5a9 Mon Sep 17 00:00:00 2001 From: Clar Charr Date: Thu, 26 Jan 2017 23:25:05 -0500 Subject: [PATCH] Path::is_empty --- src/libstd/path.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/libstd/path.rs b/src/libstd/path.rs index eb0a6cd74d7bc..3ccd9ce730942 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1490,6 +1490,24 @@ impl Path { PathBuf::from(self.inner.to_os_string()) } + /// Checks whether the `Path` is empty. + /// + /// # Examples + /// + /// ``` + /// use std::path::Path; + /// + /// let path = Path::new(""); + /// assert!(path.is_empty()) + /// + /// let path = Path::new("tmp"); + /// assert!(!path.is_empty()) + /// ``` + #[unstable(feature = "path_is_empty", issue = "0")] + pub fn is_empty(&self) -> bool { + self.inner.is_empty() + } + /// A path is *absolute* if it is independent of the current directory. /// /// * On Unix, a path is absolute if it starts with the root, so