1
Fork 0

use and_then/flat_map for map().flatten()

This commit is contained in:
Matthias Krüger 2023-04-01 23:50:45 +02:00
parent ac229c2819
commit 5a07e33d2c
5 changed files with 7 additions and 10 deletions

View file

@ -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