diff --git a/generate_arrayvec_copy b/generate_arrayvec_copy index bf3b150..b27f508 100755 --- a/generate_arrayvec_copy +++ b/generate_arrayvec_copy @@ -12,6 +12,7 @@ sed \ -e "s/struct \\([A-Za-z_]*\\)<\\('[A-Za-z_]*, \\)\\?T,/struct \\1<\\2T: Copy,/g" \ -e "s/fn \\([A-Za-z_]*\\)<\\('[A-Za-z_]*, \\)\\?T:/fn \\1<\\2T: Copy +/g" \ -e "s/fn \\([A-Za-z_]*\\)<\\('[A-Za-z_]*, \\)\\?T,/fn \\1<\\2T: Copy,/g" \ + -e "s/const fn/fn/" \ src/arrayvec.rs \ > src/arrayvec_copy_generated.rs diff --git a/src/arrayvec_copy.patch b/src/arrayvec_copy.patch index 00744a9..16fd8fb 100644 --- a/src/arrayvec_copy.patch +++ b/src/arrayvec_copy.patch @@ -1,8 +1,12 @@ diff --git a/src/arrayvec_copy_generated.rs b/src/arrayvec_copy.rs -index b12aa9e..5597af9 100644 +index f61b5b3..fab45ec 100644 --- a/src/arrayvec_copy_generated.rs +++ b/src/arrayvec_copy.rs -@@ -27,6 +27,9 @@ use crate::utils::MakeMaybeUninit; +@@ -23,10 +23,12 @@ use serde::{Serialize, Deserialize, Serializer, Deserializer}; + use crate::LenUint; + use crate::errors::CapacityError; + use crate::arrayvec_impl::ArrayVecImpl; +-use crate::utils::MakeMaybeUninit; /// A vector with a fixed capacity. /// @@ -12,7 +16,7 @@ index b12aa9e..5597af9 100644 /// The `ArrayVecCopy` is a vector backed by a fixed size array. It keeps track of /// the number of initialized elements. The `ArrayVecCopy` is parameterized /// by `T` for the element type and `CAP` for the maximum capacity. -@@ -46,14 +49,6 @@ pub struct ArrayVecCopy { +@@ -46,14 +48,6 @@ pub struct ArrayVecCopy { xs: [MaybeUninit; CAP], } @@ -27,7 +31,28 @@ index b12aa9e..5597af9 100644 macro_rules! panic_oob { ($method_name:expr, $index:expr, $len:expr) => { panic!(concat!("ArrayVecCopy::", $method_name, ": index {} is out of bounds in vector of length {}"), -@@ -964,21 +959,6 @@ impl DoubleEndedIterator for IntoIter { +@@ -87,20 +81,6 @@ impl ArrayVecCopy { + } + } + +- /// Create a new empty `ArrayVecCopy` (fn). +- /// +- /// The maximum capacity is given by the generic parameter `CAP`. +- /// +- /// ``` +- /// use arrayvec::ArrayVecCopy; +- /// +- /// static ARRAY: ArrayVecCopy = ArrayVecCopy::new_const(); +- /// ``` +- pub fn new_const() -> ArrayVecCopy { +- assert_capacity_limit_const!(CAP); +- ArrayVecCopy { xs: MakeMaybeUninit::ARRAY, len: 0 } +- } +- + /// Return the number of elements in the `ArrayVecCopy`. + /// + /// ``` +@@ -964,21 +944,6 @@ impl DoubleEndedIterator for IntoIter { impl ExactSizeIterator for IntoIter { } diff --git a/src/arrayvec_copy.rs b/src/arrayvec_copy.rs index 5597af9..fab45ec 100644 --- a/src/arrayvec_copy.rs +++ b/src/arrayvec_copy.rs @@ -23,7 +23,6 @@ use serde::{Serialize, Deserialize, Serializer, Deserializer}; use crate::LenUint; use crate::errors::CapacityError; use crate::arrayvec_impl::ArrayVecImpl; -use crate::utils::MakeMaybeUninit; /// A vector with a fixed capacity. /// @@ -82,20 +81,6 @@ impl ArrayVecCopy { } } - /// Create a new empty `ArrayVecCopy` (const fn). - /// - /// The maximum capacity is given by the generic parameter `CAP`. - /// - /// ``` - /// use arrayvec::ArrayVecCopy; - /// - /// static ARRAY: ArrayVecCopy = ArrayVecCopy::new_const(); - /// ``` - pub const fn new_const() -> ArrayVecCopy { - assert_capacity_limit_const!(CAP); - ArrayVecCopy { xs: MakeMaybeUninit::ARRAY, len: 0 } - } - /// Return the number of elements in the `ArrayVecCopy`. /// /// ``` @@ -106,7 +91,7 @@ impl ArrayVecCopy { /// assert_eq!(array.len(), 2); /// ``` #[inline(always)] - pub const fn len(&self) -> usize { self.len as usize } + pub fn len(&self) -> usize { self.len as usize } /// Returns whether the `ArrayVecCopy` is empty. /// @@ -118,7 +103,7 @@ impl ArrayVecCopy { /// assert_eq!(array.is_empty(), true); /// ``` #[inline] - pub const fn is_empty(&self) -> bool { self.len() == 0 } + pub fn is_empty(&self) -> bool { self.len() == 0 } /// Return the capacity of the `ArrayVecCopy`. /// @@ -129,7 +114,7 @@ impl ArrayVecCopy { /// assert_eq!(array.capacity(), 3); /// ``` #[inline(always)] - pub const fn capacity(&self) -> usize { CAP } + pub fn capacity(&self) -> usize { CAP } /// Return true if the `ArrayVecCopy` is completely filled to its capacity, false otherwise. /// @@ -141,7 +126,7 @@ impl ArrayVecCopy { /// array.push(1); /// assert!(array.is_full()); /// ``` - pub const fn is_full(&self) -> bool { self.len() == self.capacity() } + pub fn is_full(&self) -> bool { self.len() == self.capacity() } /// Returns the capacity left in the `ArrayVecCopy`. /// @@ -152,7 +137,7 @@ impl ArrayVecCopy { /// array.pop(); /// assert_eq!(array.remaining_capacity(), 1); /// ``` - pub const fn remaining_capacity(&self) -> usize { + pub fn remaining_capacity(&self) -> usize { self.capacity() - self.len() }