We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
rename_directory
1 parent 6a92395 commit f7a132fCopy full SHA for f7a132f
library/std/src/fs/tests.rs
@@ -1595,3 +1595,19 @@ fn test_read_dir_infinite_loop() {
1595
// Check for duplicate errors
1596
assert!(dir.filter(|e| e.is_err()).take(2).count() < 2);
1597
}
1598
+
1599
+#[test]
1600
+fn rename_directory() {
1601
+ let tmpdir = tmpdir();
1602
+ let old_path = tmpdir.join("foo/bar/baz");
1603
+ fs::create_dir_all(&old_path).unwrap();
1604
+ let test_file = &old_path.join("temp.txt");
1605
1606
+ File::create(test_file).unwrap();
1607
1608
+ let new_path = tmpdir.join("quux/blat");
1609
+ fs::create_dir_all(&new_path).unwrap();
1610
+ fs::rename(&old_path, &new_path.join("newdir")).unwrap();
1611
+ assert!(new_path.join("newdir").is_dir());
1612
+ assert!(new_path.join("newdir/temp.txt").exists());
1613
+}
tests/ui-fulldeps/std/rename-directory.rs
0 commit comments