Pass thru buffer serialize Err

It is more helpful to pass thru the error because "couldn't serialize" does not help the developer to resolve the issue.
This commit is contained in:
nworbnhoj 2022-04-23 13:11:52 +10:00 committed by GitHub
parent ac8decce88
commit 00af36d6de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -230,7 +230,7 @@ impl<'a> Buffer<'a> {
let copied_slice =
unsafe { core::slice::from_raw_parts_mut(self.slice.as_mut_ptr(), self.slice.len()) };
let mut ser = rkyv::ser::serializers::BufferSerializer::new(copied_slice);
let pos = ser.serialize_value(&src).or(Err("couldn't serialize"))?;
let pos = ser.serialize_value(&src).map_err(|err| err).unwrap();
self.offset = MemoryAddress::new(pos);
if let Some(ref mut msg) = self.memory_message.as_mut() {
msg.offset = MemoryAddress::new(pos);