From 10e697ad2f705e8c1b8c8405ab8cd13904182871 Mon Sep 17 00:00:00 2001 From: 52 Date: Wed, 7 Feb 2024 02:51:09 +0100 Subject: [PATCH] feat(tuple): added method --- src/clarity/tuple.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/clarity/tuple.rs b/src/clarity/tuple.rs index 32af105..985b733 100644 --- a/src/clarity/tuple.rs +++ b/src/clarity/tuple.rs @@ -48,6 +48,13 @@ impl TupleCV { pub fn iter_mut(&mut self) -> std::slice::IterMut { self.0.iter_mut() } + + /// Gets a value from the underlying vector from a `TupleCV` instance. + pub fn get(&self, key: &str) -> Option<&ClarityValue> { + self.0 + .iter() + .find_map(|(k, v)| if k == key { Some(v) } else { None }) + } } impl IntoIterator for TupleCV {