Skip to content

Commit

Permalink
Guard unsafe impl example
Browse files Browse the repository at this point in the history
Fix Layout import in examples

Signed-off-by: Tin Švagelj <[email protected]>
  • Loading branch information
Caellian committed Mar 22, 2024
1 parent d964574 commit bcd5dd7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<A> = ImplDefault,
A: ManageMemory = DefaultMemoryManager,
Expand Down Expand Up @@ -463,7 +463,7 @@ impl<Impl: ImplDetails<A>, A: ManageMemory> ContiguousMemory<Impl, A> {
/// 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?
Expand Down
6 changes: 4 additions & 2 deletions src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
Expand Down

0 comments on commit bcd5dd7

Please sign in to comment.