@@ -112,28 +112,28 @@ const BUILT_AS_WELL: StaticVec<MyStruct, 3> =
112112// You can even do quite a bit with a StaticVec inside of a top-level const block.
113113static BLOCKY : StaticVec < MyOtherStruct , 6 > = const {
114114 let mut a = staticvec ! [
115+ MyOtherStruct { s: "a" } ,
116+ MyOtherStruct { s: "b" } ,
117+ MyOtherStruct { s: "c" } ,
118+ ] ;
119+ let b = staticvec ! [
115120 MyOtherStruct { s: "d" } ,
116121 MyOtherStruct { s: "e" } ,
117122 MyOtherStruct { s: "f" }
118123 ] ;
119- let mut b = StaticVec :: < MyOtherStruct , 6 > :: new ( ) ;
120- let iter_slice = staticvec ! [
121- MyOtherStruct { s: "a" } ,
122- MyOtherStruct { s: "b" } ,
123- MyOtherStruct { s: "c" } ,
124- ]
125- . iter ( )
126- . as_slice ( ) ;
127- b. insert ( 0 , iter_slice[ 0 ] . clone ( ) ) ;
128- b. insert ( 1 , iter_slice[ 1 ] . clone ( ) ) ;
129- b. insert ( 2 , iter_slice[ 2 ] . clone ( ) ) ;
130- b. append ( & mut a) ;
131- // `a` is now empty, but we have to "forget" it anyways to make this work in a const context in
132- // conjunction with the `const_precise_live_drops` feature currently. Note that the reason the
133- // `build` const fn did not require any use of `mem::forget` is that we only created a single
134- // StaticVec instance within it which was directly used as the return value.
124+ let mut c = StaticVec :: < MyOtherStruct , 6 > :: new ( ) ;
125+ let iter_slice = b. iter ( ) . as_slice ( ) ;
126+ c. insert ( 0 , iter_slice[ 0 ] . clone ( ) ) ;
127+ c. insert ( 1 , iter_slice[ 1 ] . clone ( ) ) ;
128+ c. insert ( 2 , iter_slice[ 2 ] . clone ( ) ) ;
129+ c. append ( & mut a) ;
130+ // `a` is now empty, but we have to "forget" it and `b` anyways to make this work in a const
131+ // context in conjunction with the `const_precise_live_drops` feature currently. Note that the
132+ // reason the `build` const fn did not require any use of `mem::forget` is that we only created
133+ // a single StaticVec instance within it which was directly used as the return value.
135134 forget ( a) ;
136- b
135+ forget ( b) ;
136+ c
137137} ;
138138
139139static BLOCKIER : StaticVec < i32 , 12 > = const {
0 commit comments