use try_fold
instead of fold
This commit is contained in:
parent
e77a8f439c
commit
827cb1b2a7
2 changed files with 2 additions and 3 deletions
|
@ -1057,8 +1057,7 @@ impl Place {
|
|||
/// In order to retrieve the correct type, the `locals` argument must match the list of all
|
||||
/// locals from the function body where this place originates from.
|
||||
pub fn ty(&self, locals: &[LocalDecl]) -> Result<Ty, Error> {
|
||||
let start_ty = locals[self.local].ty;
|
||||
self.projection.iter().fold(Ok(start_ty), |place_ty, elem| elem.ty(place_ty?))
|
||||
self.projection.iter().try_fold(locals[self.local].ty, |place_ty, elem| elem.ty(place_ty))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -563,7 +563,7 @@ pub struct PlaceRef<'a> {
|
|||
impl PlaceRef<'_> {
|
||||
/// Get the type of this place.
|
||||
pub fn ty(&self, locals: &[LocalDecl]) -> Result<Ty, Error> {
|
||||
self.projection.iter().fold(Ok(locals[self.local].ty), |place_ty, elem| elem.ty(place_ty?))
|
||||
self.projection.iter().try_fold(locals[self.local].ty, |place_ty, elem| elem.ty(place_ty))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue