Sign In

arrayvec

Package Overview
Dependencies
Maintainers
0
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arrayvec - cargo Package Compare versions

Comparing version
0.1.2
to
0.2.0
+2
-0
.travis.yml

@@ -11,3 +11,5 @@ language: rust

cargo test --verbose --features "$FEATURES"
cargo test --verbose --manifest-path=nodrop/Cargo.toml
cargo bench --verbose --features "$FEATURES" -- --test
cargo bench --verbose --manifest-path=nodrop/Cargo.toml -- --test
cargo doc --verbose --features "$FEATURES"
+6
-2
[package]
name = "arrayvec"
version = "0.1.2"
version = "0.2.0"
authors = ["bluss"]
license = "MIT/Apache-2.0"
description = "A vector with a fixed capacity."
description = "A vector with a fixed capacity, it can be stored on the stack too."
documentation = "http://bluss.github.io/arrayvec"

@@ -12,1 +12,5 @@ repository = "https://github.com/bluss/arrayvec"

keywords = ["stack", "vector", "array", "container", "data-structure"]
[dependencies]
nodrop = "0.1"
docs: VERSION
cargo doc --no-deps
cargo doc
rm -rf ./doc

@@ -5,0 +5,0 @@ cp -r ./target/doc ./doc

@@ -11,3 +11,3 @@

|build_status|_ |crates|_
|build_status|_ |crates|_ |crates2|_

@@ -20,2 +20,5 @@ .. |build_status| image:: https://travis-ci.org/bluss/arrayvec.svg

.. |crates2| image:: http://meritbadge.herokuapp.com/nodrop
.. _crates2: https://crates.io/crates/nodrop
License

@@ -22,0 +25,0 @@ =======

@@ -0,1 +1,5 @@

extern crate nodrop;
use nodrop::NoDrop;
use std::iter;

@@ -15,9 +19,2 @@ use std::mem;

/// Make sure the non-nullable pointer optimization does not occur!
#[repr(u8)]
enum Flag<T> {
Dropped,
Alive(T),
}
/// Trait for fixed size arrays.

@@ -81,3 +78,3 @@ pub unsafe trait Array {

pub struct ArrayVec<A: Array> {
xs: Flag<A>,
xs: NoDrop<A>,
len: u8,

@@ -88,7 +85,4 @@ }

fn drop(&mut self) {
// clear all elements, then inhibit drop of inner array
// clear all elements, then NoDrop inhibits drop of inner array
while let Some(_) = self.pop() { }
unsafe {
ptr::write(&mut self.xs, Flag::Dropped);
}
}

@@ -115,25 +109,6 @@ }

unsafe {
ArrayVec { xs: Flag::Alive(Array::new()), len: 0 }
ArrayVec { xs: NoDrop::new(Array::new()), len: 0 }
}
}
#[inline]
fn inner_ref(&self) -> &A {
match self.xs {
Flag::Alive(ref xs) => xs,
_ => unreachable!(),
//_ => std::intrinsics::unreachable(),
}
}
#[inline]
fn inner_mut(&mut self) -> &mut A {
// FIXME: Optimize this, we know it's always Some.
match self.xs {
Flag::Alive(ref mut xs) => xs,
_ => unreachable!(),
//_ => std::intrinsics::unreachable(),
}
}
/// Return the number of elements in the **ArrayVec**.

@@ -228,3 +203,3 @@ ///

unsafe {
slice::from_raw_parts(self.inner_ref().as_ptr(), self.len())
slice::from_raw_parts(self.xs.as_ptr(), self.len())
}

@@ -239,3 +214,3 @@ }

unsafe {
slice::from_raw_parts_mut(self.inner_mut().as_mut_ptr(), len)
slice::from_raw_parts_mut(self.xs.as_mut_ptr(), len)
}

@@ -257,3 +232,3 @@ }

fn from(array: A) -> Self {
ArrayVec { xs: Flag::Alive(array), len: A::capacity() as u8 }
ArrayVec { xs: NoDrop::new(array), len: A::capacity() as u8 }
}

@@ -549,18 +524,13 @@ }

#[test]
fn test_no_nonnullable_opt() {
// Make sure `Flag` does not apply the non-nullable pointer optimization
// as Option would do.
assert!(mem::size_of::<Flag<&i32>>() > mem::size_of::<&i32>());
assert!(mem::size_of::<Flag<Vec<i32>>>() > mem::size_of::<Vec<i32>>());
}
#[test]
fn test_compact_size() {
// 4 elements size + 1 len + 1 enum tag + [1 drop flag]
// Future rust will kill these drop flags!
// 4 elements size + 1 len + 1 enum tag + [1 drop flag] + [1 drop flag nodrop]
type ByteArray = ArrayVec<[u8; 4]>;
assert!(mem::size_of::<ByteArray>() <= 7);
println!("{}", mem::size_of::<ByteArray>());
assert!(mem::size_of::<ByteArray>() <= 8);
// 12 element size + 1 len + 1 drop flag + 2 padding + 1 enum tag + 3 padding
type QuadArray = ArrayVec<[u32; 3]>;
assert!(mem::size_of::<QuadArray>() <= 20);
println!("{}", mem::size_of::<QuadArray>());
assert!(mem::size_of::<QuadArray>() <= 24);
}

@@ -1,1 +0,1 @@

arrayvec - 0.1.2
arrayvec - 0.2.0