diff options
author | David Tolnay <dtolnay@chromium.org> | 2018-12-14 13:46:48 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-12-18 00:42:52 -0800 |
commit | 1dda82e8b288f538145abe15fbd42606edfc5c2a (patch) | |
tree | 21c2ce10c453b5948b0b660904d0c1981d19cc13 /sys_util/src/guest_memory.rs | |
parent | 63bc050f5a160fa98e588c4850d82d49d7c3518d (diff) | |
download | crosvm-1dda82e8b288f538145abe15fbd42606edfc5c2a.tar crosvm-1dda82e8b288f538145abe15fbd42606edfc5c2a.tar.gz crosvm-1dda82e8b288f538145abe15fbd42606edfc5c2a.tar.bz2 crosvm-1dda82e8b288f538145abe15fbd42606edfc5c2a.tar.lz crosvm-1dda82e8b288f538145abe15fbd42606edfc5c2a.tar.xz crosvm-1dda82e8b288f538145abe15fbd42606edfc5c2a.tar.zst crosvm-1dda82e8b288f538145abe15fbd42606edfc5c2a.zip |
sys_util: Combine GuestMemory::with_regions and with_regions_mut
Every implementation of Fn also implements FnMut, so if some callback can be passed to GuestMemory::with_regions then it could also have been passed to GuestMemory::with_regions_mut. This CL removes GuestMemory::with_regions and renames with_regions_mut to with_regions. TEST=cargo check Change-Id: Ia4f168ff4eb4d45a5ee8f9413821ae244fb72ee1 Reviewed-on: https://chromium-review.googlesource.com/1378688 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: David Tolnay <dtolnay@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org>
Diffstat (limited to 'sys_util/src/guest_memory.rs')
-rw-r--r-- | sys_util/src/guest_memory.rs | 18 |
1 files changed, 1 insertions, 17 deletions
diff --git a/sys_util/src/guest_memory.rs b/sys_util/src/guest_memory.rs index 6644ff2..157800c 100644 --- a/sys_util/src/guest_memory.rs +++ b/sys_util/src/guest_memory.rs @@ -142,23 +142,7 @@ impl GuestMemory { } /// Perform the specified action on each region's addresses. - pub fn with_regions<F, E>(&self, cb: F) -> result::Result<(), E> - where - F: Fn(usize, GuestAddress, usize, usize) -> result::Result<(), E>, - { - for (index, region) in self.regions.iter().enumerate() { - cb( - index, - region.guest_base, - region.mapping.size(), - region.mapping.as_ptr() as usize, - )?; - } - Ok(()) - } - - /// Perform the specified action on each region's addresses mutably. - pub fn with_regions_mut<F, E>(&self, mut cb: F) -> result::Result<(), E> + pub fn with_regions<F, E>(&self, mut cb: F) -> result::Result<(), E> where F: FnMut(usize, GuestAddress, usize, usize) -> result::Result<(), E>, { |