File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -1863,6 +1863,16 @@ impl Path {
1863
1863
1864
1864
/// Checks if the path buffer is empty. On Windows, it will return false if the inner string is
1865
1865
/// invalid unicode. On Unix, this is a no-op.
1866
+ ///
1867
+ /// # Examples
1868
+ ///
1869
+ /// ```
1870
+ /// use std::path::Path;
1871
+ ///
1872
+ /// let path = Path::new("/tmp/foo.rs");
1873
+ ///
1874
+ /// assert!(!path.is_empty());
1875
+ /// ```
1866
1876
#[ unstable( feature = "path_extras" , reason = "recently added" , issue = "30259" ) ]
1867
1877
pub fn is_empty ( & self ) -> bool {
1868
1878
if let Some ( b) = self . inner . to_bytes ( ) {
@@ -3200,6 +3210,17 @@ mod tests {
3200
3210
}
3201
3211
}
3202
3212
3213
+ #[ test]
3214
+ pub fn is_empty ( ) {
3215
+ let path = Path :: new ( "/tmp/foo.rs" ) ;
3216
+ let mut path_buf = PathBuf :: new ( ) ;
3217
+
3218
+ assert ! ( !path. is_empty( ) ) ;
3219
+ assert ! ( path_buf. is_empty( ) ) ;
3220
+ path_buf. push ( "catsarecute" ) ;
3221
+ assert ! ( !path_buf. is_empty( ) ) ;
3222
+ }
3223
+
3203
3224
#[ test]
3204
3225
pub fn test_set_extension ( ) {
3205
3226
macro_rules! tfe(
You can’t perform that action at this time.
0 commit comments