Skip to content

Commit 07e6534

Browse files
apply suggestions
Signed-off-by: Xiangfei Ding <[email protected]>
1 parent 9913176 commit 07e6534

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

library/core/src/init.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ use crate::ptr::Pointee;
2626
/// If initialization was successful, then [`Self::init`] returns the metadata that combined with
2727
/// the pointer to the given to [`Self::init`] yields a valid pointer to `T`.
2828
///
29-
/// ```
29+
/// ``` ignore (illustrative)
3030
/// use std::alloc::alloc;
31-
/// fn init_unsized<T: ?Sized + Pointee, I: Init<T>>(init: I) -> Result<Box<T>, I::Error> {
31+
/// fn init_boxed<T: ?Sized + Pointee, I: Init<T>>(init: I) -> Result<Box<T>, I::Error> {
3232
/// let layout = init.layout();
3333
/// let memory = alloc(layout).cast::<()>();
3434
/// let meta = init.init(memory)?;
@@ -64,6 +64,9 @@ pub unsafe trait Init<T: ?Sized + Pointee> {
6464
type Error;
6565

6666
/// The layout needed by this initializer.
67+
/// This method must return a layout that precisely matches
68+
/// with `T`.
69+
/// Namely the size and the alignment must be equal.
6770
#[lang = "init_layout"]
6871
fn layout(&self) -> crate::alloc::Layout;
6972

0 commit comments

Comments
 (0)