@@ -799,7 +799,7 @@ pub unsafe trait PinInit<T: ?Sized, E = Infallible>: Sized {
799
799
///
800
800
/// [`Arc<T>`]: crate::sync::Arc
801
801
#[ must_use = "An initializer must be used in order to create its value." ]
802
- pub unsafe trait Init < T : ?Sized , E = Infallible > : Sized {
802
+ pub unsafe trait Init < T : ?Sized , E = Infallible > : PinInit < T , E > {
803
803
/// Initializes `slot`.
804
804
///
805
805
/// # Safety
@@ -810,18 +810,6 @@ pub unsafe trait Init<T: ?Sized, E = Infallible>: Sized {
810
810
unsafe fn __init ( self , slot : * mut T ) -> Result < ( ) , E > ;
811
811
}
812
812
813
- // SAFETY: Every in-place initializer can also be used as a pin-initializer.
814
- unsafe impl < T : ?Sized , E , I > PinInit < T , E > for I
815
- where
816
- I : Init < T , E > ,
817
- {
818
- unsafe fn __pinned_init ( self , slot : * mut T ) -> Result < ( ) , E > {
819
- // SAFETY: `__init` meets the same requirements as `__pinned_init`, except that it does not
820
- // require `slot` to not move after init.
821
- unsafe { self . __init ( slot) }
822
- }
823
- }
824
-
825
813
/// Creates a new [`PinInit<T, E>`] from the given closure.
826
814
///
827
815
/// # Safety
@@ -964,6 +952,13 @@ unsafe impl<T, E> Init<T, E> for T {
964
952
}
965
953
}
966
954
955
+ // SAFETY: Every type can be initialized by-value. `__pinned_init` calls `__init`.
956
+ unsafe impl < T , E > PinInit < T , E > for T {
957
+ unsafe fn __pinned_init ( self , slot : * mut T ) -> Result < ( ) , E > {
958
+ unsafe { self . __init ( slot) }
959
+ }
960
+ }
961
+
967
962
/// Smart pointer that can initialize memory in-place.
968
963
pub trait InPlaceInit < T > : Sized {
969
964
/// Use the given pin-initializer to pin-initialize a `T` inside of a new smart pointer of this
0 commit comments