Skip to content

Commit

Permalink
Add as_arc_str() and as_arc_slice() methods on FieldValue. (#414)
Browse files Browse the repository at this point in the history
  • Loading branch information
obi1kenobi authored Jul 29, 2023
1 parent 9cc00b1 commit c38126b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions trustfall_core/src/ir/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ impl FieldValue {
}
}

pub fn as_arc_str(&self) -> Option<&Arc<str>> {
match self {
FieldValue::String(s) => Some(s),
_ => None,
}
}

pub fn as_bool(&self) -> Option<bool> {
match self {
FieldValue::Boolean(b) => Some(*b),
Expand All @@ -190,6 +197,13 @@ impl FieldValue {
}
}

pub fn as_arc_slice(&self) -> Option<&Arc<[FieldValue]>> {
match self {
FieldValue::List(l) => Some(l),
_ => None,
}
}

pub fn as_vec_with<'a, T>(
&'a self,
inner: impl Fn(&'a FieldValue) -> Option<T>,
Expand Down

0 comments on commit c38126b

Please sign in to comment.