This commit is contained in:
Andrea Fioraldi 2020-12-10 10:07:09 +01:00
parent 67f6aecb6b
commit 892fb2ed76
2 changed files with 14 additions and 28 deletions

View File

@ -6,7 +6,7 @@ use core::slice::from_raw_parts_mut;
use num::Integer;
use serde::{Deserialize, Serialize};
use crate::serde_anymap::{SerdeAny, ArrayMut};
use crate::serde_anymap::{ArrayMut, SerdeAny};
use crate::AflError;
// TODO register each observer in the Registry in new()
@ -29,8 +29,6 @@ pub trait Observer: SerdeAny + 'static {
crate::create_serde_registry_for_trait!(observer_serde, crate::observers::Observer);
/// A MapObserver observes the static map, as oftentimes used for afl-like coverage information
pub trait MapObserver<T>
where

View File

@ -539,12 +539,8 @@ where
impl<T: Sized + serde::Serialize> Array<T> {
pub fn as_slice(&self) -> &[T] {
match self {
Array::Cptr(p) => {
unsafe { core::slice::from_raw_parts(p.0, p.1) }
},
Array::Owned(v) => {
v.as_slice()
}
Array::Cptr(p) => unsafe { core::slice::from_raw_parts(p.0, p.1) },
Array::Owned(v) => v.as_slice(),
}
}
}
@ -578,23 +574,15 @@ where
impl<T: Sized + serde::Serialize> ArrayMut<T> {
pub fn as_slice(&self) -> &[T] {
match self {
ArrayMut::Cptr(p) => {
unsafe { core::slice::from_raw_parts(p.0, p.1) }
},
ArrayMut::Owned(v) => {
v.as_slice()
}
ArrayMut::Cptr(p) => unsafe { core::slice::from_raw_parts(p.0, p.1) },
ArrayMut::Owned(v) => v.as_slice(),
}
}
pub fn as_mut_slice(&mut self) -> &mut [T] {
match self {
ArrayMut::Cptr(p) => {
unsafe { core::slice::from_raw_parts_mut(p.0, p.1) }
},
ArrayMut::Owned(v) => {
v.as_mut_slice()
}
ArrayMut::Cptr(p) => unsafe { core::slice::from_raw_parts_mut(p.0, p.1) },
ArrayMut::Owned(v) => v.as_mut_slice(),
}
}
}