Skip to content

Commit

Permalink
Merge pull request #116 from bluss/maybe-uninit-for-0.5
Browse files Browse the repository at this point in the history
Update ArrayString to use union and prepare for 0.5
  • Loading branch information
bluss authored Dec 18, 2018
2 parents 7496a5f + 74745a9 commit 345d420
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 72 deletions.
39 changes: 19 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,42 @@ env:
- FEATURES='serde-1'
matrix:
include:
- rust: 1.20.0
- rust: stable
env:
- NODEFAULT=1
- NODROP_FEATURES='use_needs_drop'
- rust: 1.22.1
- rust: 1.24.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
- ARRAYVECTEST_ENSURE_UNION=1
- ARRAYVECTEST_ENSURE_UNION=1
- rust: nightly
env:
- NODROP_FEATURES='use_needs_drop'
- FEATURES='serde'
- ARRAYVECTEST_ENSURE_UNION=1
- rust: nightly
env:
- FEATURES='serde use_union'
- NODROP_FEATURES='use_union'
- FEATURES='serde-1'
- ARRAYVECTEST_ENSURE_UNION=1
- rust: nightly
env:
- FEATURES='array-sizes-33-128 array-sizes-129-255'
branches:
only:
- master
- 0.4
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 -v --no-default-features &&
cargo build -v --features "$FEATURES" &&
cargo test -v --features "$FEATURES" &&
cargo test -v --release --features "$FEATURES" &&
cargo bench -v --features "$FEATURES" --no-run &&
cargo doc -v --features "$FEATURES" &&
cargo build -v --manifest-path=nodrop/Cargo.toml &&
cargo test -v --manifest-path=nodrop/Cargo.toml
3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ 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

0 comments on commit 345d420

Please sign in to comment.