Skip to content

Use const generics in ArrayVec #172

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

Merged
merged 12 commits into from
Mar 23, 2021
7 changes: 3 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ env:
jobs:
tests:
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
include:
- rust: 1.36.0 # MSRV
- rust: 1.51.0 # MSRV
features: serde
- rust: stable
features: serde
- rust: stable
features: array-sizes-33-128 array-sizes-129-255
features:
- rust: beta
features: serde
- rust: nightly
Expand Down
3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ default = ["std"]
std = []
unstable-const-fn = []

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

[profile.bench]
debug = true
[profile.release]
Expand Down
12 changes: 6 additions & 6 deletions benches/arraystring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use arrayvec::ArrayString;
use bencher::Bencher;

fn try_push_c(b: &mut Bencher) {
let mut v = ArrayString::<[u8; 512]>::new();
let mut v = ArrayString::<512>::new();
b.iter(|| {
v.clear();
while v.try_push('c').is_ok() {
Expand All @@ -18,7 +18,7 @@ fn try_push_c(b: &mut Bencher) {
}

fn try_push_alpha(b: &mut Bencher) {
let mut v = ArrayString::<[u8; 512]>::new();
let mut v = ArrayString::<512>::new();
b.iter(|| {
v.clear();
while v.try_push('α').is_ok() {
Expand All @@ -30,7 +30,7 @@ fn try_push_alpha(b: &mut Bencher) {

// Yes, pushing a string char-by-char is slow. Use .push_str.
fn try_push_string(b: &mut Bencher) {
let mut v = ArrayString::<[u8; 512]>::new();
let mut v = ArrayString::<512>::new();
let input = "abcαβγ“”";
b.iter(|| {
v.clear();
Expand All @@ -45,7 +45,7 @@ fn try_push_string(b: &mut Bencher) {
}

fn push_c(b: &mut Bencher) {
let mut v = ArrayString::<[u8; 512]>::new();
let mut v = ArrayString::<512>::new();
b.iter(|| {
v.clear();
while !v.is_full() {
Expand All @@ -57,7 +57,7 @@ fn push_c(b: &mut Bencher) {
}

fn push_alpha(b: &mut Bencher) {
let mut v = ArrayString::<[u8; 512]>::new();
let mut v = ArrayString::<512>::new();
b.iter(|| {
v.clear();
while !v.is_full() {
Expand All @@ -69,7 +69,7 @@ fn push_alpha(b: &mut Bencher) {
}

fn push_string(b: &mut Bencher) {
let mut v = ArrayString::<[u8; 512]>::new();
let mut v = ArrayString::<512>::new();
let input = "abcαβγ“”";
b.iter(|| {
v.clear();
Expand Down
10 changes: 5 additions & 5 deletions benches/extend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use bencher::Bencher;
use bencher::black_box;

fn extend_with_constant(b: &mut Bencher) {
let mut v = ArrayVec::<[u8; 512]>::new();
let mut v = ArrayVec::<u8, 512>::new();
let cap = v.capacity();
b.iter(|| {
v.clear();
Expand All @@ -22,7 +22,7 @@ fn extend_with_constant(b: &mut Bencher) {
}

fn extend_with_range(b: &mut Bencher) {
let mut v = ArrayVec::<[u8; 512]>::new();
let mut v = ArrayVec::<u8, 512>::new();
let cap = v.capacity();
b.iter(|| {
v.clear();
Expand All @@ -34,7 +34,7 @@ fn extend_with_range(b: &mut Bencher) {
}

fn extend_with_slice(b: &mut Bencher) {
let mut v = ArrayVec::<[u8; 512]>::new();
let mut v = ArrayVec::<u8, 512>::new();
let data = [1; 512];
b.iter(|| {
v.clear();
Expand All @@ -46,7 +46,7 @@ fn extend_with_slice(b: &mut Bencher) {
}

fn extend_with_write(b: &mut Bencher) {
let mut v = ArrayVec::<[u8; 512]>::new();
let mut v = ArrayVec::<u8, 512>::new();
let data = [1; 512];
b.iter(|| {
v.clear();
Expand All @@ -57,7 +57,7 @@ fn extend_with_write(b: &mut Bencher) {
}

fn extend_from_slice(b: &mut Bencher) {
let mut v = ArrayVec::<[u8; 512]>::new();
let mut v = ArrayVec::<u8, 512>::new();
let data = [1; 512];
b.iter(|| {
v.clear();
Expand Down
151 changes: 0 additions & 151 deletions src/array.rs

This file was deleted.

Loading