From bcd5dd7301733cf3571d239a128aeb18a7549d15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tin=20=C5=A0vagelj?= Date: Fri, 22 Mar 2024 19:03:07 +0100 Subject: [PATCH] Guard unsafe impl example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix Layout import in examples Signed-off-by: Tin Å vagelj --- src/lib.rs | 12 ++++++------ src/memory.rs | 6 ++++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 6893330..63df4e3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -46,11 +46,11 @@ use types::*; /// ``` #[doc = include_str!("../examples/default_impl.rs")] /// ``` -/// -/// ## Unsafe Implementation -/// ``` -#[doc = include_str!("../examples/unsafe_impl.rs")] -/// ``` +#[cfg_attr(feature = "unsafe_impl", doc = "")] +#[cfg_attr(feature = "unsafe_impl", doc = "## Unsafe Implementation")] +#[cfg_attr(feature = "unsafe_impl", doc = "```")] +#[cfg_attr(feature = "unsafe_impl", doc = include_str!("../examples/unsafe_impl.rs"))] +#[cfg_attr(feature = "unsafe_impl", doc = "```")] pub struct ContiguousMemory< Impl: ImplDetails = ImplDefault, A: ManageMemory = DefaultMemoryManager, @@ -463,7 +463,7 @@ impl, A: ManageMemory> ContiguousMemory { /// use contiguous_mem::ContiguousMemory; /// /// let mut s: ContiguousMemory = ContiguousMemory::new(); - /// + /// /// assert!(s.try_grow_to(1024).is_ok()); /// /// let required_size: usize = usize::MAX; // bad read? diff --git a/src/memory.rs b/src/memory.rs index 4ccf140..477ce75 100644 --- a/src/memory.rs +++ b/src/memory.rs @@ -236,7 +236,8 @@ impl SegmentTracker { /// /// ``` /// # use contiguous_mem::range::ByteRange; - /// # use contiguous_mem::memory::{alloc::Layout, SegmentTracker}; + /// # use contiguous_mem::memory::SegmentTracker; + /// # use core::alloc::Layout; /// let mut tracker = SegmentTracker::new(1024); /// /// let layout = Layout::from_size_align(128, 8).unwrap(); @@ -263,7 +264,8 @@ impl SegmentTracker { /// # Examples /// ``` /// # use contiguous_mem::range::ByteRange; - /// # use contiguous_mem::memory::{alloc::Layout, SegmentTracker}; + /// # use contiguous_mem::memory::SegmentTracker; + /// # use core::alloc::Layout; /// let mut tracker = SegmentTracker::new(1024); /// /// let range = tracker