From b49cf79661bba3c546be419a61b15756065c5a0a Mon Sep 17 00:00:00 2001 From: Johannes Stoelp Date: Fri, 29 Apr 2022 00:37:33 +0200 Subject: minor cleanup --- src/lib.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 5f51ba0..df4a7e3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -289,20 +289,20 @@ impl Elf<'_, N> { let w = (flags & PF_W) != 0; let r = (flags & PF_R) != 0; - load_segments_slice = if let Some((slot, rest)) = load_segments_slice.split_first_mut() - { - *slot = Some(LoadSegment { - vaddr, - bytes, - zero_pad: memsz - filesz, - x, - w, - r, - }); - rest - } else { - return Err(Error::OutOfLoadSegments); - }; + load_segments_slice = load_segments_slice + .split_first_mut() + .map(|(slot, rest)| { + *slot = Some(LoadSegment { + vaddr, + bytes, + zero_pad: memsz - filesz, + x, + w, + r, + }); + rest + }) + .ok_or(Error::OutOfLoadSegments)?; } Ok(Elf { -- cgit v1.2.3