Skip to content

Commit

Permalink
Fix up the argument order in the docs as well
Browse files Browse the repository at this point in the history
  • Loading branch information
TethysSvensson committed Nov 12, 2019
1 parent 941b3b7 commit 14446bc
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ impl Bump {
///
/// ```
/// let bump = bumpalo::Bump::new();
/// let x = bump.alloc_slice_fill_copy(5, 42);
/// let x = bump.alloc_slice_fill_copy(42, 5);
/// assert_eq!(x, &[42, 42, 42, 42, 42]);
/// ```
#[inline(always)]
Expand All @@ -670,7 +670,9 @@ impl Bump {
ptr::write(dst.as_ptr().add(i), value);
}

slice::from_raw_parts_mut(dst.as_ptr(), len)
let result = slice::from_raw_parts_mut(dst.as_ptr(), len);
debug_assert_eq!(Layout::for_value(result), layout);
result
}
}

Expand All @@ -688,7 +690,7 @@ impl Bump {
/// ```
/// let bump = bumpalo::Bump::new();
/// let s: String = "Hello Bump!".to_string();
/// let x: &[String] = bump.alloc_slice_fill_clone(2, &s);
/// let x: &[String] = bump.alloc_slice_fill_clone(&s, 2);
/// assert_eq!(x.len(), 2);
/// assert_eq!(&x[0], &s);
/// assert_eq!(&x[1], &s);
Expand All @@ -708,7 +710,9 @@ impl Bump {
ptr::write(dst.as_ptr().add(i), value.clone());
}

slice::from_raw_parts_mut(dst.as_ptr(), len)
let result = slice::from_raw_parts_mut(dst.as_ptr(), len);
debug_assert_eq!(Layout::for_value(result), layout);
result
}
}

Expand Down Expand Up @@ -743,7 +747,9 @@ impl Bump {
ptr::write(dst.as_ptr().add(i), T::default());
}

slice::from_raw_parts_mut(dst.as_ptr(), len)
let result = slice::from_raw_parts_mut(dst.as_ptr(), len);
debug_assert_eq!(Layout::for_value(result), layout);
result
}
}

Expand Down

0 comments on commit 14446bc

Please sign in to comment.