From 1dda82e8b288f538145abe15fbd42606edfc5c2a Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 14 Dec 2018 13:46:48 -0800 Subject: 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 Tested-by: David Tolnay Reviewed-by: Stephen Barber --- sys_util/src/guest_memory.rs | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'sys_util/src/guest_memory.rs') 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(&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(&self, mut cb: F) -> result::Result<(), E> + pub fn with_regions(&self, mut cb: F) -> result::Result<(), E> where F: FnMut(usize, GuestAddress, usize, usize) -> result::Result<(), E>, { -- cgit 1.4.1