File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments