use and_then/flat_map for map().flatten()
This commit is contained in:
parent
ac229c2819
commit
5a07e33d2c
5 changed files with 7 additions and 10 deletions
|
@ -79,7 +79,7 @@ impl<'tcx> ValTree<'tcx> {
|
|||
}
|
||||
|
||||
pub fn try_to_target_usize(self, tcx: TyCtxt<'tcx>) -> Option<u64> {
|
||||
self.try_to_scalar_int().map(|s| s.try_to_target_usize(tcx).ok()).flatten()
|
||||
self.try_to_scalar_int().and_then(|s| s.try_to_target_usize(tcx).ok())
|
||||
}
|
||||
|
||||
/// Get the values inside the ValTree as a slice of bytes. This only works for
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue