feat: add method ensure_init runnable at will without overhead
This commit is contained in:
12
01.workspace/heave/src/imp/catalog_ensure_init.rs
Normal file
12
01.workspace/heave/src/imp/catalog_ensure_init.rs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
use crate::*;
|
||||||
|
|
||||||
|
impl Catalog {
|
||||||
|
pub fn ensure_init(&mut self) -> Result<(), FailedTo> {
|
||||||
|
if self.already_init {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
let result = self.init()?;
|
||||||
|
self.already_init = true;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
pub mod bool_try_from_value;
|
pub mod bool_try_from_value;
|
||||||
pub mod catalog_contains_key;
|
pub mod catalog_contains_key;
|
||||||
pub mod catalog_delete;
|
pub mod catalog_delete;
|
||||||
|
pub mod catalog_ensure_init;
|
||||||
pub mod catalog_for_each;
|
pub mod catalog_for_each;
|
||||||
pub mod catalog_for_each_mut;
|
pub mod catalog_for_each_mut;
|
||||||
pub mod catalog_get;
|
pub mod catalog_get;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ use std::sync::*;
|
|||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct O {
|
pub struct O {
|
||||||
pub(crate) path: String,
|
pub(crate) path: String,
|
||||||
|
pub(crate) already_init: bool,
|
||||||
items: Mutex<HashMap<String, Entity>>,
|
items: Mutex<HashMap<String, Entity>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user