Small refactor with Iterator::reduce
This commit is contained in:
parent
f9435f4c92
commit
c89b9d97e2
1 changed files with 2 additions and 3 deletions
|
@ -1111,10 +1111,9 @@ impl<'a> Resolver<'a> {
|
||||||
_,
|
_,
|
||||||
) = binding.kind
|
) = binding.kind
|
||||||
{
|
{
|
||||||
let def_id = (&*self).parent(ctor_def_id).expect("no parent for a constructor");
|
let def_id = self.parent(ctor_def_id).expect("no parent for a constructor");
|
||||||
let fields = self.field_names.get(&def_id)?;
|
let fields = self.field_names.get(&def_id)?;
|
||||||
let first_field = fields.first()?; // Handle `struct Foo()`
|
return fields.iter().map(|name| name.span).reduce(Span::to); // None for `struct Foo()`
|
||||||
return Some(fields.iter().fold(first_field.span, |acc, field| acc.to(field.span)));
|
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue