Skip to content

Commit

Permalink
Struct method tidying
Browse files Browse the repository at this point in the history
  • Loading branch information
zslayton committed Dec 11, 2024
1 parent 160b519 commit 558d33a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lazy/expanded/struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,11 @@ impl<'top, D: Decoder> LazyExpandedStruct<'top, D> {
}

pub fn find(&self, name: &str) -> IonResult<Option<LazyExpandedValue<'top, D>>> {
use ExpandedStructSource::*;
match &self.source {
// If we're reading from a struct in a template, consult its field index to see if one or
// more fields with the requested name exist.
ExpandedStructSource::Template(environment, element, index) => {
Template(environment, element, index) => {
let Some(value_expr_addresses) = index.get(name) else {
// If the field name is not in the index, it's not in the struct.
return Ok(None);
Expand Down Expand Up @@ -284,7 +285,7 @@ impl<'top, D: Decoder> LazyExpandedStruct<'top, D> {
}
// For any other kind of struct, do a linear scan over its fields until we encounter
// one with the requested name.
_ => {
ValueLiteral(..) | MakeField(..) | MakeStruct(..) => {
for field_result in self.iter() {
let field = field_result?;
if field.name().read()?.text() == Some(name) {
Expand Down

0 comments on commit 558d33a

Please sign in to comment.