feat: add unwrap_opt function to entity to unwrap optional values

This commit is contained in:
2025-10-01 06:33:56 +02:00
parent 1a890ea98a
commit ddd1957c44

View File

@@ -64,6 +64,12 @@ impl O {
.map(|value| T::from(value.clone()))
.unwrap()
}
pub fn unwrap_opt<T>(&self, id: &str) -> Option<T>
where
T: From<Value>,
{
self.value_of(id).map(|value| T::from(value.clone()))
}
pub fn unwrap_or<T>(&self, id: &str, default: T) -> T
where
T: From<Value>,