@@ -52,15 +52,12 @@ impl<T, A: Alloc> RawVec<T, A> {
52
52
/// Like `new`, but parameterized over the choice of allocator for
53
53
/// the returned `RawVec`.
54
54
pub const fn new_in ( a : A ) -> Self {
55
- // `!0` is `usize::MAX`. This branch should be stripped at compile time.
56
- // FIXME(mark-i-m): use this line when `if`s are allowed in `const`:
57
- //let cap = if mem::size_of::<T>() == 0 { !0 } else { 0 };
55
+ let cap = if mem:: size_of :: < T > ( ) == 0 { core:: usize:: MAX } else { 0 } ;
58
56
59
57
// `Unique::empty()` doubles as "unallocated" and "zero-sized allocation".
60
58
RawVec {
61
59
ptr : Unique :: empty ( ) ,
62
- // FIXME(mark-i-m): use `cap` when ifs are allowed in const
63
- cap : [ 0 , !0 ] [ ( mem:: size_of :: < T > ( ) == 0 ) as usize ] ,
60
+ cap,
64
61
a,
65
62
}
66
63
}
@@ -132,19 +129,7 @@ impl<T> RawVec<T, Global> {
132
129
/// `RawVec` with capacity `usize::MAX`. Useful for implementing
133
130
/// delayed allocation.
134
131
pub const fn new ( ) -> Self {
135
- // FIXME(Centril): Reintegrate this with `fn new_in` when we can.
136
-
137
- // `!0` is `usize::MAX`. This branch should be stripped at compile time.
138
- // FIXME(mark-i-m): use this line when `if`s are allowed in `const`:
139
- //let cap = if mem::size_of::<T>() == 0 { !0 } else { 0 };
140
-
141
- // `Unique::empty()` doubles as "unallocated" and "zero-sized allocation".
142
- RawVec {
143
- ptr : Unique :: empty ( ) ,
144
- // FIXME(mark-i-m): use `cap` when ifs are allowed in const
145
- cap : [ 0 , !0 ] [ ( mem:: size_of :: < T > ( ) == 0 ) as usize ] ,
146
- a : Global ,
147
- }
132
+ Self :: new_in ( Global )
148
133
}
149
134
150
135
/// Creates a `RawVec` (on the system heap) with exactly the
0 commit comments