Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a stop-gap “MaybeUninit” using ManuallyDrop #97

Closed
wants to merge 12 commits into from
Closed
32 changes: 13 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,34 @@ env:
- FEATURES='serde-1'
matrix:
include:
- rust: 1.20.0
- rust: stable
env:
- NODEFAULT=1
- NODROP_FEATURES='use_needs_drop'
- rust: 1.22.1
env:
- FEATURES='array-sizes-33-128 array-sizes-129-255'
- rust: stable
- rust: stable
env:
- FEATURES='serde-1'
- rust: stable
env:
- FEATURES='array-sizes-33-128 array-sizes-129-255'
- rust: beta
- rust: nightly
env:
- NODEFAULT=1
- FEATURES='serde-1'
- rust: nightly
env:
- NODROP_FEATURES='use_needs_drop'
- FEATURES='serde-1'
- rust: nightly
env:
- FEATURES='serde use_union'
- NODROP_FEATURES='use_union'
- FEATURES='array-sizes-33-128 array-sizes-129-255'
branches:
only:
- master
- 0.3
script:
- |
([ ! -z "$NODROP_FEATURES" ] || cargo build --verbose --features "$FEATURES") &&
([ "$NODEFAULT" != 1 ] || cargo build --verbose --no-default-features) &&
([ ! -z "$NODROP_FEATURES" ] || cargo test --verbose --features "$FEATURES") &&
([ ! -z "$NODROP_FEATURES" ] || cargo test --release --verbose --features "$FEATURES") &&
([ ! -z "$NODROP_FEATURES" ] || cargo bench --verbose --features "$FEATURES" -- --test) &&
([ ! -z "$NODROP_FEATURES" ] || cargo doc --verbose --features "$FEATURES") &&
([ "$NODEFAULT" != 1 ] || cargo build --verbose --manifest-path=nodrop/Cargo.toml --no-default-features) &&
cargo test --verbose --manifest-path=nodrop/Cargo.toml --features "$NODROP_FEATURES" &&
cargo bench --verbose --manifest-path=nodrop/Cargo.toml --features "$NODROP_FEATURES" -- --test
cargo build --verbose --no-default-features &&
cargo build --verbose --features "$FEATURES" &&
cargo test --verbose --features "$FEATURES" &&
cargo test --release --verbose --features "$FEATURES" &&
cargo bench --verbose --features "$FEATURES" --no-run &&
cargo doc --verbose --features "$FEATURES"
7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ repository = "https://github.com/bluss/arrayvec"
keywords = ["stack", "vector", "array", "data-structure", "no_std"]
categories = ["data-structures", "no-std"]

[build-dependencies]

[dependencies]
nodrop = { version = "0.1.12", path = "nodrop", default-features = false }

[dependencies.serde]
version = "1.0"
Expand All @@ -37,12 +38,14 @@ harness = false
[features]
default = ["std"]
std = []
use_union = []
serde-1 = ["serde"]

array-sizes-33-128 = []
array-sizes-129-255 = []

# has no effect
use_union = []

[package.metadata.docs.rs]
features = ["serde-1"]

Expand Down
10 changes: 4 additions & 6 deletions src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
pub unsafe trait Array {
/// The array’s element type
type Item;
/// The smallest type that can index and tell the length of the array.
#[doc(hidden)]
/// The smallest index type that indexes the array.
type Index: Index;
/// The array's element capacity
const CAPACITY: usize;
#[doc(hidden)]
fn as_ptr(&self) -> *const Self::Item;
#[doc(hidden)]
fn as_mut_ptr(&mut self) -> *mut Self::Item;
#[doc(hidden)]
fn capacity() -> usize;
}

Expand Down Expand Up @@ -91,14 +91,12 @@ macro_rules! fix_array_impl {
unsafe impl<T> Array for [T; $len] {
type Item = T;
type Index = $index_type;
const CAPACITY: usize = $len;
#[doc(hidden)]
#[inline(always)]
fn as_ptr(&self) -> *const T { self as *const _ as *const _ }
#[doc(hidden)]
#[inline(always)]
fn as_mut_ptr(&mut self) -> *mut T { self as *mut _ as *mut _}
#[doc(hidden)]
#[inline(always)]
fn capacity() -> usize { $len }
}
)
Expand Down
Loading