unsafe fn try_allocate_for_layout(
        value_layout: Layout,
        allocate: impl FnOnce(Layout) -> Result<NonNull<[u8]>, AllocError>,
        mem_to_arcinner: impl FnOnce(*mut u8) -> *mut StrongArcInner<T>,
    ) -> Result<*mut StrongArcInner<T>, AllocError> {
        // Calculate layout using the given value layout.
        // Previously, layout was calculated on the expression
        // `&*(ptr as *const ArcInner<T>)`, but this created a misaligned
        // reference (see #54908).
        let layout = Layout::new::<StrongArcInner<()>>()
            .extend(value_layout)
            .unwrap()
            .0
            .pad_to_align();

        let ptr = allocate(layout)?;

        // Initialize the ArcInner
        let inner = mem_to_arcinner(ptr.as_non_null_ptr().as_ptr());
        debug_assert_eq!(Layout::for_value(&*inner), layout);

        ptr::write(&mut (*inner).strong, atomic::AtomicU32::new(1));

        Ok(inner)
    }
/// Allocates an `StrongArcInner<T>` with sufficient space for
/// a possibly-unsized inner value where the value has the layout provided,
/// returning an error if allocation fails.
///
/// The function `mem_to_arcinner` is called with the data pointer
/// and must return back a (potentially fat)-pointer for the `StrongArcInner<T>`.
Allocates an `StrongArcInner` with sufficient space for
a possibly-unsized inner value where the value has the layout provided,
returning an error if allocation fails.

The function `mem_to_arcinner` is called with the data pointer
and must return back a (potentially fat)-pointer for the `StrongArcInner`.
Allocates an ` StrongArcInner ` with sufficient space for a possibly - unsized inner value where the value has the layout provided returning an error if allocation fails . The function ` mem_to_arcinner ` is called with the data pointer and must return back a ( potentially fat ) - pointer for the ` StrongArcInner ` .
unsafe fn try_allocate_for_layout(
        value_layout: Layout,
        allocate: impl FnOnce(Layout) -> Result<NonNull<[u8]>, AllocError>,
        mem_to_arcinner: impl FnOnce(*mut u8) -> *mut StrongArcInner<T>,
    ) -> Result<*mut StrongArcInner<T>, AllocError> {
        // Calculate layout using the given value layout.
        // Previously, layout was calculated on the expression
        // `&*(ptr as *const ArcInner<T>)`, but this created a misaligned
        // reference (see #54908).
        let layout = Layout::new::<StrongArcInner<()>>()
            .extend(value_layout)
            .unwrap()
            .0
            .pad_to_align();
        let ptr = allocate(layout)?;
        // Initialize the ArcInner
        let inner = mem_to_arcinner(ptr.as_non_null_ptr().as_ptr());
        debug_assert_eq!(Layout::for_value(&*inner), layout);
        ptr::write(&mut (*inner).strong, atomic::AtomicU32::new(1));
        Ok(inner)
    }
unsafe fn try_allocate_for_layout ( value_layout : Layout , allocate : impl FnOnce ( Layout ) -> Result < NonNull < [ u8 ] > , AllocError > , mem_to_arcinner : impl FnOnce ( * mut u8 ) -> * mut StrongArcInner < T > , ) -> Result < * mut StrongArcInner < T > , AllocError > { // Calculate layout using the given value layout. // Previously, layout was calculated on the expression // `&*(ptr as *const ArcInner<T>)`, but this created a misaligned // reference (see #54908). let layout = Layout :: new :: < StrongArcInner < ( ) > > ( ) . extend ( value_layout ) . unwrap ( ) . 0 . pad_to_align ( ) ; let ptr = allocate ( layout ) ? ; // Initialize the ArcInner let inner = mem_to_arcinner ( ptr . as_non_null_ptr ( ) . as_ptr ( ) ) ; debug_assert_eq ! ( Layout for_value ( inner ) layout ) ; ptr :: write ( & mut ( * inner ) . strong , atomic :: AtomicU32 :: new ( 1 ) ) ; Ok ( inner ) }
Allocates an `StrongArcInner<T>` with sufficient space for
a possibly-unsized inner value where the value has the layout provided,
returning an error if allocation fails.
Allocates an ` StrongArcInner<T > ` with sufficient space for a possibly - unsized inner value where the value has the layout provided returning an error if allocation fails .
value_layout
Layout
allocate
impl FnOnce(Layout) -> Result<NonNull<[u8]>, AllocError>
mem_to_arcinner
impl FnOnce(*mut u8) -> *mut StrongArcInner<T>
value_layout
Layout
allocate
impl FnOnce(Layout) -> Result<NonNull<[u8]>, AllocError>
mem_to_arcinner
impl FnOnce(*mut u8) -> *mut StrongArcInner<T>