From e1e828980914ece7d47bb2f883f98c7865c0e24b Mon Sep 17 00:00:00 2001 From: Edward Barnard Date: Tue, 1 May 2018 20:20:37 +0100 Subject: Remove last bit of unsafe code. --- src/binary/reader.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/binary') diff --git a/src/binary/reader.rs b/src/binary/reader.rs index 5878836..bee34f7 100644 --- a/src/binary/reader.rs +++ b/src/binary/reader.rs @@ -158,8 +158,7 @@ impl EventReader { fn read_data(&mut self, len: u64) -> Result> { let mut data = self.allocate_vec(len, size_of::())?; - // Safe as u8 is a Copy type and we have already know len has been allocated. - unsafe { data.set_len(len as usize) } + data.resize(len as usize, 0); self.reader.read_exact(&mut data)?; Ok(data) } @@ -229,9 +228,9 @@ impl EventReader { (0x3, 3) => { // Date. Seconds since 1/1/2001 00:00:00. let secs = self.reader.read_f64::()?; - Some(PlistEvent::DateValue( - Date::from_seconds_since_plist_epoch(secs)?, - )) + Some(PlistEvent::DateValue(Date::from_seconds_since_plist_epoch( + secs, + )?)) } (0x4, n) => { // Data -- cgit v1.2.3