feat: add method ensure_init runnable at will without overhead

This commit is contained in:
2025-11-14 16:32:34 +01:00
parent e316ec83a3
commit 98e50faa4e
3 changed files with 14 additions and 0 deletions

View 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(())
}
}

View File

@@ -1,6 +1,7 @@
pub mod bool_try_from_value;
pub mod catalog_contains_key;
pub mod catalog_delete;
pub mod catalog_ensure_init;
pub mod catalog_for_each;
pub mod catalog_for_each_mut;
pub mod catalog_get;

View File

@@ -10,6 +10,7 @@ use std::sync::*;
#[derive(Debug, Default)]
pub struct O {
pub(crate) path: String,
pub(crate) already_init: bool,
items: Mutex<HashMap<String, Entity>>,
}