Try to get rid of owned types

Inspired by https://www.youtube.com/watch?v=A4cKi7PTJSs. This turns a
lot of cloning Strings and PathBufs into Rcs.
This commit is contained in:
Adrian Heine 2023-06-17 14:53:38 +02:00
parent e3b425eb1c
commit d091265d27
20 changed files with 343 additions and 232 deletions

View file

@ -16,7 +16,7 @@ fn get_dir<'a, I: IntoIterator<Item = &'a &'a str>>(content: I) -> TempDir {
}
fn get_storage(path: &Path) -> SimpleStorage {
SimpleStorage::new(path.join("_filename"))
SimpleStorage::new(path.join("_filename").into())
}
// Normal cases
@ -33,7 +33,7 @@ fn single_file() {
);
assert_eq!(
dir.path().join("_filename").join("12345"),
Path::new(&storage.read_filename().unwrap())
Path::new(&*storage.read_filename().unwrap())
);
assert_eq!(storage.recent_date().unwrap(), 12345);
}
@ -50,7 +50,7 @@ fn two_files() {
);
assert_eq!(
dir.path().join("_filename").join("23456"),
Path::new(&storage.read_filename().unwrap())
Path::new(&*storage.read_filename().unwrap())
);
assert_eq!(storage.recent_date().unwrap(), 23456);
}
@ -67,7 +67,7 @@ fn another_two_files() {
);
assert_eq!(
dir.path().join("_filename").join("23456"),
Path::new(&storage.read_filename().unwrap())
Path::new(&*storage.read_filename().unwrap())
);
assert_eq!(storage.recent_date().unwrap(), 23456);
}
@ -84,7 +84,7 @@ fn three_files() {
);
assert_eq!(
dir.path().join("_filename").join("23456"),
Path::new(&storage.read_filename().unwrap())
Path::new(&*storage.read_filename().unwrap())
);
assert_eq!(storage.recent_date().unwrap(), 23456);
}