Allow for reading raw bytes from rustc_serialize::Decoder without unsafe code.
This commit is contained in:
parent
dbc37a97dc
commit
517d5ac230
5 changed files with 48 additions and 45 deletions
|
@ -188,7 +188,6 @@ use std::collections::{BTreeMap, HashMap};
|
|||
use std::io;
|
||||
use std::io::prelude::*;
|
||||
use std::mem::swap;
|
||||
use std::mem::MaybeUninit;
|
||||
use std::num::FpCategory as Fp;
|
||||
use std::ops::Index;
|
||||
use std::str::FromStr;
|
||||
|
@ -2367,10 +2366,9 @@ impl crate::Decoder for Decoder {
|
|||
expect!(self.pop(), String).map(Cow::Owned)
|
||||
}
|
||||
|
||||
fn read_raw_bytes(&mut self, s: &mut [MaybeUninit<u8>]) -> Result<(), Self::Error> {
|
||||
fn read_raw_bytes_into(&mut self, s: &mut [u8]) -> Result<(), Self::Error> {
|
||||
for c in s.iter_mut() {
|
||||
let h = self.read_u8()?;
|
||||
unsafe { *c.as_mut_ptr() = h };
|
||||
*c = self.read_u8()?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue