diff --git a/lib/core/libimagrt/src/runtime.rs b/lib/core/libimagrt/src/runtime.rs index 994bfa5b..8766cda7 100644 --- a/lib/core/libimagrt/src/runtime.rs +++ b/lib/core/libimagrt/src/runtime.rs @@ -132,7 +132,7 @@ impl<'a> Runtime<'a> { let store_result = if cli_app.use_inmemory_fs() { Store::new_with_backend(storepath, &config, - Box::new(InMemoryFileAbstraction::new())) + Box::new(InMemoryFileAbstraction::default())) } else { Store::new(storepath, &config) }; diff --git a/lib/core/libimagstore/src/file_abstraction/inmemory.rs b/lib/core/libimagstore/src/file_abstraction/inmemory.rs index d3445b54..efe0c4f4 100644 --- a/lib/core/libimagstore/src/file_abstraction/inmemory.rs +++ b/lib/core/libimagstore/src/file_abstraction/inmemory.rs @@ -87,19 +87,13 @@ impl FileAbstractionInstance for InMemoryFileAbstractionInstance { } } -#[derive(Debug)] +#[derive(Debug, Default)] pub struct InMemoryFileAbstraction { virtual_filesystem: Backend, } impl InMemoryFileAbstraction { - pub fn new() -> InMemoryFileAbstraction { - InMemoryFileAbstraction { - virtual_filesystem: Arc::new(Mutex::new(RefCell::new(HashMap::new()))), - } - } - pub fn backend(&self) -> &Backend { &self.virtual_filesystem } diff --git a/lib/core/libimagstore/src/file_abstraction/mod.rs b/lib/core/libimagstore/src/file_abstraction/mod.rs index b6ca5e00..893b8ca2 100644 --- a/lib/core/libimagstore/src/file_abstraction/mod.rs +++ b/lib/core/libimagstore/src/file_abstraction/mod.rs @@ -104,7 +104,7 @@ mod test { #[test] fn lazy_file() { - let fs = InMemoryFileAbstraction::new(); + let fs = InMemoryFileAbstraction::default(); let mut path = PathBuf::from("tests"); path.set_file_name("test1"); @@ -124,7 +124,7 @@ Hello World"#, env!("CARGO_PKG_VERSION"))).unwrap(); #[test] fn lazy_file_multiline() { - let fs = InMemoryFileAbstraction::new(); + let fs = InMemoryFileAbstraction::default(); let mut path = PathBuf::from("tests"); path.set_file_name("test1"); @@ -145,7 +145,7 @@ baz"#, env!("CARGO_PKG_VERSION"))).unwrap(); #[test] fn lazy_file_multiline_trailing_newlines() { - let fs = InMemoryFileAbstraction::new(); + let fs = InMemoryFileAbstraction::default(); let mut path = PathBuf::from("tests"); path.set_file_name("test1"); diff --git a/lib/core/libimagstore/src/store.rs b/lib/core/libimagstore/src/store.rs index 039b6b3f..5a7868a9 100644 --- a/lib/core/libimagstore/src/store.rs +++ b/lib/core/libimagstore/src/store.rs @@ -1176,7 +1176,7 @@ mod store_tests { use file_abstraction::InMemoryFileAbstraction; pub fn get_store() -> Store { - let backend = Box::new(InMemoryFileAbstraction::new()); + let backend = Box::new(InMemoryFileAbstraction::default()); Store::new_with_backend(PathBuf::from("/"), &None, backend).unwrap() } @@ -1361,7 +1361,7 @@ mod store_tests { use file_abstraction::InMemoryFileAbstraction; let mut store = { - let backend = InMemoryFileAbstraction::new(); + let backend = InMemoryFileAbstraction::default(); let backend = Box::new(backend); Store::new_with_backend(PathBuf::from("/"), &None, backend).unwrap() @@ -1377,7 +1377,7 @@ mod store_tests { } { - let other_backend = InMemoryFileAbstraction::new(); + let other_backend = InMemoryFileAbstraction::default(); let other_backend = Box::new(other_backend); assert!(store.reset_backend(other_backend).is_ok()) diff --git a/lib/domain/libimagtimetrack/src/iter/mod.rs b/lib/domain/libimagtimetrack/src/iter/mod.rs index ffe212c7..f0648ce2 100644 --- a/lib/domain/libimagtimetrack/src/iter/mod.rs +++ b/lib/domain/libimagtimetrack/src/iter/mod.rs @@ -37,7 +37,7 @@ mod test { use std::path::PathBuf; use libimagstore::file_abstraction::InMemoryFileAbstraction; - let backend = Box::new(InMemoryFileAbstraction::new()); + let backend = Box::new(InMemoryFileAbstraction::default()); Store::new_with_backend(PathBuf::from("/"), &None, backend).unwrap() } diff --git a/lib/entry/libimagentrycategory/src/register.rs b/lib/entry/libimagentrycategory/src/register.rs index 88c3e645..aa75ab4f 100644 --- a/lib/entry/libimagentrycategory/src/register.rs +++ b/lib/entry/libimagentrycategory/src/register.rs @@ -127,7 +127,7 @@ mod tests { pub fn get_store() -> Store { use libimagstore::store::InMemoryFileAbstraction; - let backend = Box::new(InMemoryFileAbstraction::new()); + let backend = Box::new(InMemoryFileAbstraction::default()); Store::new_with_backend(PathBuf::from("/"), &None, backend).unwrap() } diff --git a/lib/entry/libimagentrydatetime/src/datetime.rs b/lib/entry/libimagentrydatetime/src/datetime.rs index 8d6217e3..6eb6683d 100644 --- a/lib/entry/libimagentrydatetime/src/datetime.rs +++ b/lib/entry/libimagentrydatetime/src/datetime.rs @@ -207,7 +207,7 @@ mod tests { pub fn get_store() -> Store { use libimagstore::store::InMemoryFileAbstraction; - let backend = Box::new(InMemoryFileAbstraction::new()); + let backend = Box::new(InMemoryFileAbstraction::default()); Store::new_with_backend(PathBuf::from("/"), &None, backend).unwrap() } diff --git a/lib/entry/libimagentrygps/src/entry.rs b/lib/entry/libimagentrygps/src/entry.rs index 7478f2a1..37acb075 100644 --- a/lib/entry/libimagentrygps/src/entry.rs +++ b/lib/entry/libimagentrygps/src/entry.rs @@ -113,7 +113,7 @@ mod tests { fn get_store() -> Store { use libimagstore::file_abstraction::InMemoryFileAbstraction; - let backend = Box::new(InMemoryFileAbstraction::new()); + let backend = Box::new(InMemoryFileAbstraction::default()); Store::new_with_backend(PathBuf::from("/"), &None, backend).unwrap() } diff --git a/lib/entry/libimagentrylink/src/external.rs b/lib/entry/libimagentrylink/src/external.rs index 2e9cbade..4d7d48bc 100644 --- a/lib/entry/libimagentrylink/src/external.rs +++ b/lib/entry/libimagentrylink/src/external.rs @@ -416,7 +416,7 @@ mod tests { pub fn get_store() -> Store { use libimagstore::file_abstraction::InMemoryFileAbstraction; - let backend = Box::new(InMemoryFileAbstraction::new()); + let backend = Box::new(InMemoryFileAbstraction::default()); Store::new_with_backend(PathBuf::from("/"), &None, backend).unwrap() } diff --git a/lib/entry/libimagentrylink/src/internal.rs b/lib/entry/libimagentrylink/src/internal.rs index f3eece08..e7c06fd7 100644 --- a/lib/entry/libimagentrylink/src/internal.rs +++ b/lib/entry/libimagentrylink/src/internal.rs @@ -784,7 +784,7 @@ mod test { pub fn get_store() -> Store { use libimagstore::file_abstraction::InMemoryFileAbstraction; - let backend = Box::new(InMemoryFileAbstraction::new()); + let backend = Box::new(InMemoryFileAbstraction::default()); Store::new_with_backend(PathBuf::from("/"), &None, backend).unwrap() } diff --git a/lib/entry/libimagentrymarkdown/src/processor.rs b/lib/entry/libimagentrymarkdown/src/processor.rs index 351ba321..f9b085a5 100644 --- a/lib/entry/libimagentrymarkdown/src/processor.rs +++ b/lib/entry/libimagentrymarkdown/src/processor.rs @@ -243,7 +243,7 @@ mod tests { pub fn get_store() -> Store { use libimagstore::file_abstraction::InMemoryFileAbstraction; - let fs = InMemoryFileAbstraction::new(); + let fs = InMemoryFileAbstraction::default(); Store::new_with_backend(PathBuf::from("/"), &None, Box::new(fs)).unwrap() }