| { | ||
| "git": { | ||
| "sha1": "5685049fbeefc683d22d3d5ef130d2682ed2a018" | ||
| "sha1": "0c866b32f019561875806bc7d949a0dd363a9f11" | ||
| } | ||
| } |
+1
-1
@@ -16,3 +16,3 @@ # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO | ||
| name = "arrayvec" | ||
| version = "0.7.0" | ||
| version = "0.7.1" | ||
| authors = ["bluss"] | ||
@@ -19,0 +19,0 @@ description = "A vector with fixed capacity, backed by an array (it can be stored on the stack too). Implements fixed capacity ArrayVec and ArrayString." |
+9
-0
| Recent Changes (arrayvec) | ||
| ========================= | ||
| ## 0.7.1 | ||
| - Add new ArrayVec methods `.take()` and `.into_inner_unchecked()` by @conradludgate | ||
| - `clone_from` now uses `truncate` when needed by @a1phyr | ||
| ## 0.7.0 | ||
@@ -11,4 +16,8 @@ | ||
| for analyzing the problem. | ||
| - The deprecated feature flag `unstable-const-fn` was removed, since it's not needed | ||
| - Optimize `.retain()` by using the same algorithm as in std, change by @niklasf, | ||
| issue #174. Original optimization in Rust std by @oxalica in rust-lang/rust/pull/81126 | ||
| ## 0.6.1 | ||
@@ -15,0 +24,0 @@ |
+26
-8
@@ -639,10 +639,30 @@ | ||
| } else { | ||
| unsafe { | ||
| let self_ = ManuallyDrop::new(self); | ||
| let array = ptr::read(self_.as_ptr() as *const [T; CAP]); | ||
| Ok(array) | ||
| } | ||
| unsafe { Ok(self.into_inner_unchecked()) } | ||
| } | ||
| } | ||
| /// Return the inner fixed size array. | ||
| /// | ||
| /// Safety: | ||
| /// This operation is safe if and only if length equals capacity. | ||
| pub unsafe fn into_inner_unchecked(self) -> [T; CAP] { | ||
| debug_assert_eq!(self.len(), self.capacity()); | ||
| let self_ = ManuallyDrop::new(self); | ||
| let array = ptr::read(self_.as_ptr() as *const [T; CAP]); | ||
| array | ||
| } | ||
| /// Returns the ArrayVec, replacing the original with a new empty ArrayVec. | ||
| /// | ||
| /// ``` | ||
| /// use arrayvec::ArrayVec; | ||
| /// | ||
| /// let mut v = ArrayVec::from([0, 1, 2, 3]); | ||
| /// assert_eq!([0, 1, 2, 3], v.take().into_inner().unwrap()); | ||
| /// assert!(v.is_empty()); | ||
| /// ``` | ||
| pub fn take(&mut self) -> Self { | ||
| mem::replace(self, Self::new()) | ||
| } | ||
| /// Return a slice containing all elements of the vector. | ||
@@ -1083,5 +1103,3 @@ pub fn as_slice(&self) -> &[T] { | ||
| // rhs was shorter | ||
| for _ in 0..self.len() - prefix { | ||
| self.pop(); | ||
| } | ||
| self.truncate(prefix); | ||
| } else { | ||
@@ -1088,0 +1106,0 @@ let rhs_elems = &rhs[self.len()..]; |
+1
-1
@@ -18,3 +18,3 @@ //! **arrayvec** provides the types [`ArrayVec`] and [`ArrayString`]: | ||
| //! | ||
| #![doc(html_root_url="https://docs.rs/arrayvec/0.6/")] | ||
| #![doc(html_root_url="https://docs.rs/arrayvec/0.7/")] | ||
| #![cfg_attr(not(feature="std"), no_std)] | ||
@@ -21,0 +21,0 @@ |
+24
-0
@@ -156,2 +156,17 @@ extern crate arrayvec; | ||
| // test take | ||
| flag.set(0); | ||
| { | ||
| let mut array1 = ArrayVec::<_, 3>::new(); | ||
| array1.push(Bump(flag)); | ||
| array1.push(Bump(flag)); | ||
| array1.push(Bump(flag)); | ||
| let array2 = array1.take(); | ||
| assert_eq!(flag.get(), 0); | ||
| drop(array1); | ||
| assert_eq!(flag.get(), 0); | ||
| drop(array2); | ||
| assert_eq!(flag.get(), 3); | ||
| } | ||
| // test cloning into_iter | ||
@@ -465,2 +480,11 @@ flag.set(0); | ||
| #[test] | ||
| fn test_take() { | ||
| let mut v1 = ArrayVec::<i32, 4>::new(); | ||
| v1.extend(1..=4); | ||
| let v2 = v1.take(); | ||
| assert!(v1.into_inner().is_err()); | ||
| assert_eq!(v2.into_inner().unwrap(), [1, 2, 3, 4]); | ||
| } | ||
| #[cfg(feature="std")] | ||
@@ -467,0 +491,0 @@ #[test] |
Sorry, the diff of this file is not supported yet