Skip to content

Commit

Permalink
feat(tuple): added method
Browse files Browse the repository at this point in the history
  • Loading branch information
52 committed Feb 7, 2024
1 parent 3b9fdb5 commit 10e697a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/clarity/tuple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ impl TupleCV {
pub fn iter_mut(&mut self) -> std::slice::IterMut<TupleItem> {
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 {
Expand Down

0 comments on commit 10e697a

Please sign in to comment.