File tree 2 files changed +4
-16
lines changed
2 files changed +4
-16
lines changed Original file line number Diff line number Diff line change @@ -52,14 +52,8 @@ pure fn capacity<T>(&&v: @[const T]) -> uint {
52
52
#[ inline( always) ]
53
53
pure fn build_sized < A > ( size : uint , builder : fn ( push : pure fn( +A ) ) ) -> @[ A ] {
54
54
let mut vec = @[ ] ;
55
- unsafe {
56
- unsafe :: reserve ( vec, size) ;
57
- // This is an awful hack to be able to make the push function
58
- // pure. Is there a better way?
59
- :: unsafe:: reinterpret_cast ::
60
- < fn ( push : pure fn( +A ) ) , fn ( push : fn ( +A ) ) >
61
- ( builder) ( |+x| unsafe :: push ( vec, x) ) ;
62
- }
55
+ unsafe { unsafe :: reserve ( vec, size) ; }
56
+ builder ( |+x| unsafe { unsafe :: push ( vec, x) } ) ;
63
57
return vec;
64
58
}
65
59
Original file line number Diff line number Diff line change @@ -234,14 +234,8 @@ pure fn from_slice<T: copy>(t: &[T]) -> ~[T] {
234
234
#[ inline( always) ]
235
235
pure fn build_sized < A > ( size : uint , builder : fn ( push : pure fn( +A ) ) ) -> ~[ A ] {
236
236
let mut vec = ~[ ] ;
237
- unsafe {
238
- reserve ( vec, size) ;
239
- // This is an awful hack to be able to make the push function
240
- // pure. Is there a better way?
241
- :: unsafe:: reinterpret_cast ::
242
- < fn ( push : pure fn( +A ) ) , fn ( push : fn ( +A ) ) >
243
- ( builder) ( |+x| push ( vec, x) ) ;
244
- }
237
+ unchecked { reserve( vec, size) ; }
238
+ builder ( |+x| unchecked { push( vec, x) } ) ;
245
239
return vec;
246
240
}
247
241
You can’t perform that action at this time.
0 commit comments