From ddd1957c44c7c08c526521693a29581b1296229a Mon Sep 17 00:00:00 2001 From: davidemazzocchi Date: Wed, 1 Oct 2025 06:33:56 +0200 Subject: [PATCH] feat: add unwrap_opt function to entity to unwrap optional values --- 01.workspace/heave/src/str/entity.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/01.workspace/heave/src/str/entity.rs b/01.workspace/heave/src/str/entity.rs index 30e0ebf..e080a3c 100644 --- a/01.workspace/heave/src/str/entity.rs +++ b/01.workspace/heave/src/str/entity.rs @@ -64,6 +64,12 @@ impl O { .map(|value| T::from(value.clone())) .unwrap() } + pub fn unwrap_opt(&self, id: &str) -> Option + where + T: From, + { + self.value_of(id).map(|value| T::from(value.clone())) + } pub fn unwrap_or(&self, id: &str, default: T) -> T where T: From,