Skip to content

Commit 345d420

Browse files
authored
Merge pull request #116 from bluss/maybe-uninit-for-0.5
Update ArrayString to use union and prepare for 0.5
2 parents 7496a5f + 74745a9 commit 345d420

File tree

6 files changed

+152
-72
lines changed

6 files changed

+152
-72
lines changed

.travis.yml

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,42 @@ env:
44
- FEATURES='serde-1'
55
matrix:
66
include:
7-
- rust: 1.20.0
8-
- rust: stable
9-
env:
10-
- NODEFAULT=1
11-
- NODROP_FEATURES='use_needs_drop'
12-
- rust: 1.22.1
7+
- rust: 1.24.1
138
env:
149
- FEATURES='array-sizes-33-128 array-sizes-129-255'
10+
- rust: stable
11+
- rust: stable
12+
env:
13+
- FEATURES='serde-1'
1514
- rust: stable
1615
env:
1716
- FEATURES='array-sizes-33-128 array-sizes-129-255'
1817
- rust: beta
1918
- rust: nightly
2019
env:
21-
- NODEFAULT=1
22-
- ARRAYVECTEST_ENSURE_UNION=1
20+
- ARRAYVECTEST_ENSURE_UNION=1
2321
- rust: nightly
2422
env:
25-
- NODROP_FEATURES='use_needs_drop'
23+
- FEATURES='serde'
2624
- ARRAYVECTEST_ENSURE_UNION=1
2725
- rust: nightly
2826
env:
29-
- FEATURES='serde use_union'
30-
- NODROP_FEATURES='use_union'
27+
- FEATURES='serde-1'
3128
- ARRAYVECTEST_ENSURE_UNION=1
29+
- rust: nightly
30+
env:
31+
- FEATURES='array-sizes-33-128 array-sizes-129-255'
3232
branches:
3333
only:
3434
- master
3535
- 0.4
3636
script:
3737
- |
38-
([ ! -z "$NODROP_FEATURES" ] || cargo build --verbose --features "$FEATURES") &&
39-
([ "$NODEFAULT" != 1 ] || cargo build --verbose --no-default-features) &&
40-
([ ! -z "$NODROP_FEATURES" ] || cargo test --verbose --features "$FEATURES") &&
41-
([ ! -z "$NODROP_FEATURES" ] || cargo test --release --verbose --features "$FEATURES") &&
42-
([ ! -z "$NODROP_FEATURES" ] || cargo bench --verbose --features "$FEATURES" -- --test) &&
43-
([ ! -z "$NODROP_FEATURES" ] || cargo doc --verbose --features "$FEATURES") &&
44-
([ "$NODEFAULT" != 1 ] || cargo build --verbose --manifest-path=nodrop/Cargo.toml --no-default-features) &&
45-
cargo test --verbose --manifest-path=nodrop/Cargo.toml --features "$NODROP_FEATURES" &&
46-
cargo bench --verbose --manifest-path=nodrop/Cargo.toml --features "$NODROP_FEATURES" -- --test
38+
cargo build -v --no-default-features &&
39+
cargo build -v --features "$FEATURES" &&
40+
cargo test -v --features "$FEATURES" &&
41+
cargo test -v --release --features "$FEATURES" &&
42+
cargo bench -v --features "$FEATURES" --no-run &&
43+
cargo doc -v --features "$FEATURES" &&
44+
cargo build -v --manifest-path=nodrop/Cargo.toml &&
45+
cargo test -v --manifest-path=nodrop/Cargo.toml

Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ serde-1 = ["serde"]
4444
array-sizes-33-128 = []
4545
array-sizes-129-255 = []
4646

47-
# has no effect
48-
use_union = []
49-
5047
[package.metadata.docs.rs]
5148
features = ["serde-1"]
5249

src/array.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
pub unsafe trait Array {
1616
/// The array’s element type
1717
type Item;
18+
/// The smallest type that can index and tell the length of the array.
1819
#[doc(hidden)]
19-
/// The smallest index type that indexes the array.
2020
type Index: Index;
21+
/// The array's element capacity
22+
const CAPACITY: usize;
2123
#[doc(hidden)]
2224
fn as_ptr(&self) -> *const Self::Item;
2325
#[doc(hidden)]
24-
fn as_mut_ptr(&mut self) -> *mut Self::Item;
25-
#[doc(hidden)]
2626
fn capacity() -> usize;
2727
}
2828

@@ -91,14 +91,12 @@ macro_rules! fix_array_impl {
9191
unsafe impl<T> Array for [T; $len] {
9292
type Item = T;
9393
type Index = $index_type;
94+
const CAPACITY: usize = $len;
9495
#[doc(hidden)]
9596
#[inline(always)]
9697
fn as_ptr(&self) -> *const T { self as *const _ as *const _ }
9798
#[doc(hidden)]
9899
#[inline(always)]
99-
fn as_mut_ptr(&mut self) -> *mut T { self as *mut _ as *mut _}
100-
#[doc(hidden)]
101-
#[inline(always)]
102100
fn capacity() -> usize { $len }
103101
}
104102
)

0 commit comments

Comments
 (0)