File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -156,6 +156,27 @@ impl_as_ptr!(MaybeUninit<f64>, f64);
156156impl_as_ptr ! ( MaybeUninit <c32>, lapack_sys:: __BindgenComplex<f32 >) ;
157157impl_as_ptr ! ( MaybeUninit <c64>, lapack_sys:: __BindgenComplex<f64 >) ;
158158
159+ pub ( crate ) trait VecAssureInit {
160+ type Target ;
161+ unsafe fn assure_init ( self ) -> Self :: Target ;
162+ }
163+
164+ macro_rules! impl_vec_assure_init {
165+ ( $e: ty) => {
166+ impl VecAssureInit for Vec <MaybeUninit <$e>> {
167+ type Target = Vec <$e>;
168+ unsafe fn assure_init( mut self ) -> Self :: Target {
169+ Vec :: from_raw_parts( self . as_mut_ptr( ) as * mut $e, self . len( ) , self . capacity( ) )
170+ }
171+ }
172+ } ;
173+ }
174+
175+ impl_vec_assure_init ! ( f32 ) ;
176+ impl_vec_assure_init ! ( f64 ) ;
177+ impl_vec_assure_init ! ( c32) ;
178+ impl_vec_assure_init ! ( c64) ;
179+
159180/// Upper/Lower specification for seveal usages
160181#[ derive( Debug , Clone , Copy ) ]
161182#[ repr( u8 ) ]
You can’t perform that action at this time.
0 commit comments