Use a non-dropping enum directly

Don't use NoDrop as a separate abstraction: Then we have two drop flags,
one for ArrayVec and one for NoDrop. Instead import the logic from
NoDrop. The result is a much smaller ArrayVec value.
This commit is contained in:
root
2015-07-30 16:11:08 +02:00
parent 3634fa4633
commit cf273fec1f
2 changed files with 47 additions and 11 deletions
+4 -4
View File
@@ -127,15 +127,15 @@ fn test_is_send_sync() {
#[test]
fn test_compact_size() {
// Future rust will kill these drop flags!
// 4 elements size + 1 len + 1 enum tag + [1 drop flag] + [1 drop flag nodrop]
// 4 elements size + 1 len + 1 enum tag + [1 drop flag]
type ByteArray = ArrayVec<[u8; 4]>;
println!("{}", mem::size_of::<ByteArray>());
assert!(mem::size_of::<ByteArray>() <= 8);
assert!(mem::size_of::<ByteArray>() <= 7);
// 12 element size + 1 len + 1 drop flag + 2 padding + 1 enum tag + 3 padding
// 12 element size + 1 enum tag + 3 padding + 1 len + 1 drop flag + 2 padding
type QuadArray = ArrayVec<[u32; 3]>;
println!("{}", mem::size_of::<QuadArray>());
assert!(mem::size_of::<QuadArray>() <= 24);
assert!(mem::size_of::<QuadArray>() <= 20);
}
#[test]