diff --git a/secret-memory/src/alloc/memsec/malloc.rs b/secret-memory/src/alloc/memsec/malloc.rs index 5782624..a28568a 100644 --- a/secret-memory/src/alloc/memsec/malloc.rs +++ b/secret-memory/src/alloc/memsec/malloc.rs @@ -33,13 +33,10 @@ pub type MallocVec = allocator_api2::vec::Vec; /// # Example /// ```rust /// # use rosenpass_secret_memory::alloc::memsec::malloc::{malloc_box_try, MallocBox}; -/// # fn do_test() -> Result<(), Box> { /// let data: u8 = 42; /// let malloc_box: MallocBox = malloc_box_try(data)?; /// # assert_eq!(*malloc_box, 42u8); -/// # Ok(()) -/// # } -/// # let _ = do_test(); +/// # Ok::<(), anyhow::Error>(()) /// ``` pub fn malloc_box_try(x: T) -> Result, AllocError> { MallocBox::::try_new_in(x, MallocAllocator::new()) diff --git a/secret-memory/src/alloc/memsec/memfdsec.rs b/secret-memory/src/alloc/memsec/memfdsec.rs index 4f5b063..a348b53 100644 --- a/secret-memory/src/alloc/memsec/memfdsec.rs +++ b/secret-memory/src/alloc/memsec/memfdsec.rs @@ -34,13 +34,10 @@ pub type MemfdSecVec = allocator_api2::vec::Vec; /// # Example /// ```rust /// # use rosenpass_secret_memory::alloc::memsec::memfdsec::{memfdsec_box_try, MemfdSecBox}; -/// # fn do_test() -> Result<(), Box> { /// let data: u8 = 42; /// let memfdsec_box: MemfdSecBox = memfdsec_box_try(data)?; /// # assert_eq!(*memfdsec_box, 42u8); -/// # Ok(()) -/// # } -/// # let _ = do_test(); +/// # Ok::<(), anyhow::Error>(()) /// ``` pub fn memfdsec_box_try(x: T) -> Result, AllocError> { MemfdSecBox::::try_new_in(x, MemfdSecAllocator::new()) diff --git a/secret-memory/src/alloc/mod.rs b/secret-memory/src/alloc/mod.rs index 77a9d5a..2137e21 100644 --- a/secret-memory/src/alloc/mod.rs +++ b/secret-memory/src/alloc/mod.rs @@ -30,15 +30,13 @@ static ALLOC_TYPE: OnceLock = OnceLock::new(); /// # use std::alloc::Layout; /// # use allocator_api2::alloc::Allocator; /// # use rosenpass_secret_memory::alloc::{set_secret_alloc_type, SecretAlloc, SecretAllocType}; -/// # fn do_test () -> Result<(), Box> { /// set_secret_alloc_type(SecretAllocType::MemsecMalloc); /// let secret_alloc = SecretAlloc::default(); /// unsafe { -/// let memory = secret_alloc.allocate(Layout::from_size_align_unchecked(42, 64))?; +/// let memory = secret_alloc.allocate(Layout::from_size_align_unchecked(128, 32))?; /// } -/// # Ok(()) -/// # } -/// # let _ = do_test(); +/// # Ok::<(), anyhow::Error>(()) +/// ``` /// ``` pub fn set_secret_alloc_type(alloc_type: SecretAllocType) { ALLOC_TYPE.set(alloc_type).unwrap(); @@ -128,15 +126,12 @@ pub type SecretVec = allocator_api2::vec::Vec; /// ```rust /// # use rosenpass_secret_memory::alloc::{secret_box_try, SecretBox}; /// # use rosenpass_secret_memory::alloc::SecretAllocType::MemsecMalloc; -/// # use rosenpass_secret_memory::alloc::set_secret_alloc_type; +/// use rosenpass_secret_memory::alloc::set_secret_alloc_type; /// set_secret_alloc_type(MemsecMalloc); -/// # fn do_test() -> Result<(), Box> { /// let data: u8 = 42; /// let secret_box: SecretBox = secret_box_try(data)?; /// # assert_eq!(*secret_box, 42u8); -/// # Ok(()) -/// # } -/// # let _ = do_test(); +/// # Ok::<(), anyhow::Error>(()) /// ``` pub fn secret_box_try(x: T) -> Result, AllocError> { SecretBox::::try_new_in(x, SecretAlloc::default())