From 5685049fbeefc683d22d3d5ef130d2682ed2a018 Mon Sep 17 00:00:00 2001 From: bluss Date: Mon, 29 Mar 2021 22:05:34 +0200 Subject: [PATCH] 0.7.0 --- CHANGELOG.md | 9 +++++++++ Cargo.toml | 3 +-- src/array_string.rs | 5 +---- src/arrayvec.rs | 6 +----- src/lib.rs | 4 ---- 5 files changed, 12 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d8fb05..fba82ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,15 @@ Recent Changes (arrayvec) ========================= +## 0.7.0 + +- `fn new_const` is now the way to const-construct arrayvec and arraystring, + and `fn new` has been reverted to a regular "non-const" function. + This works around performance issue #182, where the const fn version did not + optimize well. Change by @bluss with thanks to @rodrimati1992 and @niklasf + for analyzing the problem. +- The deprecated feature flag `unstable-const-fn` was removed, since it's not needed + ## 0.6.1 - The ``ArrayVec::new`` and ``ArrayString::new`` constructors are properly diff --git a/Cargo.toml b/Cargo.toml index 4252335..4e2ac02 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "arrayvec" -version = "0.6.1" +version = "0.7.0" authors = ["bluss"] license = "MIT OR Apache-2.0" edition = "2018" @@ -37,7 +37,6 @@ harness = false [features] default = ["std"] std = [] -unstable-const-fn = [] [profile.bench] debug = true diff --git a/src/array_string.rs b/src/array_string.rs index 96f57c7..fdce16a 100644 --- a/src/array_string.rs +++ b/src/array_string.rs @@ -73,10 +73,7 @@ impl ArrayString /// ``` /// use arrayvec::ArrayString; /// - /// let mut string = ArrayString::<16>::new(); - /// string.push_str("foo"); - /// assert_eq!(&string[..], "foo"); - /// assert_eq!(string.capacity(), 16); + /// static ARRAY: ArrayString<1024> = ArrayString::new_const(); /// ``` pub const fn new_const() -> ArrayString { assert_capacity_limit_const!(CAP); diff --git a/src/arrayvec.rs b/src/arrayvec.rs index 24c3f8b..5700237 100644 --- a/src/arrayvec.rs +++ b/src/arrayvec.rs @@ -91,11 +91,7 @@ impl ArrayVec { /// ``` /// use arrayvec::ArrayVec; /// - /// let mut array = ArrayVec::<_, 16>::new(); - /// array.push(1); - /// array.push(2); - /// assert_eq!(&array[..], &[1, 2]); - /// assert_eq!(array.capacity(), 16); + /// static ARRAY: ArrayVec = ArrayVec::new_const(); /// ``` pub const fn new_const() -> ArrayVec { assert_capacity_limit_const!(CAP); diff --git a/src/lib.rs b/src/lib.rs index 36ec748..d5a0320 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,10 +11,6 @@ //! - Optional //! - Enable serialization for ArrayVec and ArrayString using serde 1.x //! -//! - `unstable-const-fn` -//! - **deprecated** (has no effect) -//! - Not needed, [`ArrayVec::new`] and [`ArrayString::new`] are always `const fn` now -//! //! ## Rust Version //! //! This version of arrayvec requires Rust 1.51 or later.