Skip to content

Commit

Permalink
Move ArrayVecCopy from root to copy module.
Browse files Browse the repository at this point in the history
  • Loading branch information
tbu- committed Oct 29, 2024
1 parent 398ab39 commit 9c19f78
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 34 deletions.
5 changes: 2 additions & 3 deletions generate_arrayvec_copy
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ set -o pipefail

sed \
-e "s/\\<ArrayVec\\>/ArrayVecCopy/g" \
-e "s/\\<arrayvec::ArrayVecCopy\\>/arrayvec::copy::ArrayVecCopy/g" \
-e "s/impl<\\('[A-Za-z_]*, \\)\\?T:/impl<\\1T: Copy +/g" \
-e "s/impl<\\('[A-Za-z_]*, \\)\\?T,/impl<\\1T: Copy,/g" \
-e "s/struct \\([A-Za-z_]*\\)<\\('[A-Za-z_]*, \\)\\?T:/struct \\1<\\2T: Copy +/g" \
Expand All @@ -21,6 +22,4 @@ sed \
-e "s/const fn/fn/" \
-e "s/\\/\\/ DIRECTIVE ArrayVecCopy \\+//" \
src/arrayvec.rs \
> src/arrayvec_copy_generated.rs

mv -v -f src/arrayvec_copy_generated.rs src/arrayvec_copy.rs
> src/arrayvec_copy.rs
58 changes: 29 additions & 29 deletions src/arrayvec_copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl<T: Copy, const CAP: usize> ArrayVecCopy<T, CAP> {
/// The maximum capacity is given by the generic parameter `CAP`.
///
/// ```
/// use arrayvec::ArrayVecCopy;
/// use arrayvec::copy::ArrayVecCopy;
///
/// let mut array = ArrayVecCopy::<_, 16>::new();
/// array.push(1);
Expand All @@ -107,7 +107,7 @@ impl<T: Copy, const CAP: usize> ArrayVecCopy<T, CAP> {
/// The maximum capacity is given by the generic parameter `CAP`.
///
/// ```
/// use arrayvec::ArrayVecCopy;
/// use arrayvec::copy::ArrayVecCopy;
///
/// static ARRAY: ArrayVecCopy<u8, 1024> = ArrayVecCopy::new_const();
/// ```
Expand All @@ -119,7 +119,7 @@ impl<T: Copy, const CAP: usize> ArrayVecCopy<T, CAP> {
/// Return the number of elements in the `ArrayVecCopy`.
///
/// ```
/// use arrayvec::ArrayVecCopy;
/// use arrayvec::copy::ArrayVecCopy;
///
/// let mut array = ArrayVecCopy::from([1, 2, 3]);
/// array.pop();
Expand All @@ -131,7 +131,7 @@ impl<T: Copy, const CAP: usize> ArrayVecCopy<T, CAP> {
/// Returns whether the `ArrayVecCopy` is empty.
///
/// ```
/// use arrayvec::ArrayVecCopy;
/// use arrayvec::copy::ArrayVecCopy;
///
/// let mut array = ArrayVecCopy::from([1]);
/// array.pop();
Expand All @@ -143,7 +143,7 @@ impl<T: Copy, const CAP: usize> ArrayVecCopy<T, CAP> {
/// Return the capacity of the `ArrayVecCopy`.
///
/// ```
/// use arrayvec::ArrayVecCopy;
/// use arrayvec::copy::ArrayVecCopy;
///
/// let array = ArrayVecCopy::from([1, 2, 3]);
/// assert_eq!(array.capacity(), 3);
Expand All @@ -154,7 +154,7 @@ impl<T: Copy, const CAP: usize> ArrayVecCopy<T, CAP> {
/// Return true if the `ArrayVecCopy` is completely filled to its capacity, false otherwise.
///
/// ```
/// use arrayvec::ArrayVecCopy;
/// use arrayvec::copy::ArrayVecCopy;
///
/// let mut array = ArrayVecCopy::<_, 1>::new();
/// assert!(!array.is_full());
Expand All @@ -166,7 +166,7 @@ impl<T: Copy, const CAP: usize> ArrayVecCopy<T, CAP> {
/// Returns the capacity left in the `ArrayVecCopy`.
///
/// ```
/// use arrayvec::ArrayVecCopy;
/// use arrayvec::copy::ArrayVecCopy;
///
/// let mut array = ArrayVecCopy::from([1, 2, 3]);
/// array.pop();
Expand All @@ -181,7 +181,7 @@ impl<T: Copy, const CAP: usize> ArrayVecCopy<T, CAP> {
/// ***Panics*** if the vector is already full.
///
/// ```
/// use arrayvec::ArrayVecCopy;
/// use arrayvec::copy::ArrayVecCopy;
///
/// let mut array = ArrayVecCopy::<_, 2>::new();
///
Expand All @@ -201,7 +201,7 @@ impl<T: Copy, const CAP: usize> ArrayVecCopy<T, CAP> {
/// is already full.
///
/// ```
/// use arrayvec::ArrayVecCopy;
/// use arrayvec::copy::ArrayVecCopy;
///
/// let mut array = ArrayVecCopy::<_, 2>::new();
///
Expand Down Expand Up @@ -229,7 +229,7 @@ impl<T: Copy, const CAP: usize> ArrayVecCopy<T, CAP> {
/// This method uses *debug assertions* to check that the arrayvec is not full.
///
/// ```
/// use arrayvec::ArrayVecCopy;
/// use arrayvec::copy::ArrayVecCopy;
///
/// let mut array = ArrayVecCopy::<_, 2>::new();
///
Expand All @@ -253,7 +253,7 @@ impl<T: Copy, const CAP: usize> ArrayVecCopy<T, CAP> {
/// effect.
///
/// ```
/// use arrayvec::ArrayVecCopy;
/// use arrayvec::copy::ArrayVecCopy;
///
/// let mut array = ArrayVecCopy::from([1, 2, 3, 4, 5]);
/// array.truncate(3);
Expand Down Expand Up @@ -287,7 +287,7 @@ impl<T: Copy, const CAP: usize> ArrayVecCopy<T, CAP> {
/// `try_insert` for fallible version.
///
/// ```
/// use arrayvec::ArrayVecCopy;
/// use arrayvec::copy::ArrayVecCopy;
///
/// let mut array = ArrayVecCopy::<_, 2>::new();
///
Expand All @@ -311,7 +311,7 @@ impl<T: Copy, const CAP: usize> ArrayVecCopy<T, CAP> {
/// ***Panics*** `index` is out of bounds.
///
/// ```
/// use arrayvec::ArrayVecCopy;
/// use arrayvec::copy::ArrayVecCopy;
///
/// let mut array = ArrayVecCopy::<_, 2>::new();
///
Expand Down Expand Up @@ -352,7 +352,7 @@ impl<T: Copy, const CAP: usize> ArrayVecCopy<T, CAP> {
/// Return `Some(` *element* `)` if the vector is non-empty, else `None`.
///
/// ```
/// use arrayvec::ArrayVecCopy;
/// use arrayvec::copy::ArrayVecCopy;
///
/// let mut array = ArrayVecCopy::<_, 2>::new();
///
Expand All @@ -374,7 +374,7 @@ impl<T: Copy, const CAP: usize> ArrayVecCopy<T, CAP> {
/// ***Panics*** if the `index` is out of bounds.
///
/// ```
/// use arrayvec::ArrayVecCopy;
/// use arrayvec::copy::ArrayVecCopy;
///
/// let mut array = ArrayVecCopy::from([1, 2, 3]);
///
Expand All @@ -399,7 +399,7 @@ impl<T: Copy, const CAP: usize> ArrayVecCopy<T, CAP> {
/// Return `Some(` *element* `)` if the index is in bounds, else `None`.
///
/// ```
/// use arrayvec::ArrayVecCopy;
/// use arrayvec::copy::ArrayVecCopy;
///
/// let mut array = ArrayVecCopy::from([1, 2, 3]);
///
Expand All @@ -424,7 +424,7 @@ impl<T: Copy, const CAP: usize> ArrayVecCopy<T, CAP> {
/// ***Panics*** if the `index` is out of bounds.
///
/// ```
/// use arrayvec::ArrayVecCopy;
/// use arrayvec::copy::ArrayVecCopy;
///
/// let mut array = ArrayVecCopy::from([1, 2, 3]);
///
Expand All @@ -445,7 +445,7 @@ impl<T: Copy, const CAP: usize> ArrayVecCopy<T, CAP> {
/// is no element at `index`. Otherwise, return the element inside `Some`.
///
/// ```
/// use arrayvec::ArrayVecCopy;
/// use arrayvec::copy::ArrayVecCopy;
///
/// let mut array = ArrayVecCopy::from([1, 2, 3]);
///
Expand All @@ -470,7 +470,7 @@ impl<T: Copy, const CAP: usize> ArrayVecCopy<T, CAP> {
/// elements.
///
/// ```
/// use arrayvec::ArrayVecCopy;
/// use arrayvec::copy::ArrayVecCopy;
///
/// let mut array = ArrayVecCopy::from([1, 2, 3, 4]);
/// array.retain(|x| *x & 1 != 0 );
Expand Down Expand Up @@ -562,7 +562,7 @@ impl<T: Copy, const CAP: usize> ArrayVecCopy<T, CAP> {
/// # Examples
///
/// ```
/// use arrayvec::ArrayVecCopy;
/// use arrayvec::copy::ArrayVecCopy;
///
/// // Allocate vector big enough for 10 elements.
/// let mut v: ArrayVecCopy<i32, 10> = ArrayVecCopy::new();
Expand Down Expand Up @@ -601,7 +601,7 @@ impl<T: Copy, const CAP: usize> ArrayVecCopy<T, CAP> {
/// Copy all elements from the slice and append to the `ArrayVecCopy`.
///
/// ```
/// use arrayvec::ArrayVecCopy;
/// use arrayvec::copy::ArrayVecCopy;
///
/// let mut vec: ArrayVecCopy<usize, 10> = ArrayVecCopy::new();
/// vec.push(1);
Expand Down Expand Up @@ -645,7 +645,7 @@ impl<T: Copy, const CAP: usize> ArrayVecCopy<T, CAP> {
/// the end point is greater than the length of the vector.
///
/// ```
/// use arrayvec::ArrayVecCopy;
/// use arrayvec::copy::ArrayVecCopy;
///
/// let mut v1 = ArrayVecCopy::from([1, 2, 3]);
/// let v2: ArrayVecCopy<_, 3> = v1.drain(0..2).collect();
Expand Down Expand Up @@ -726,7 +726,7 @@ impl<T: Copy, const CAP: usize> ArrayVecCopy<T, CAP> {
/// Returns the ArrayVecCopy, replacing the original with a new empty ArrayVecCopy.
///
/// ```
/// use arrayvec::ArrayVecCopy;
/// use arrayvec::copy::ArrayVecCopy;
///
/// let mut v = ArrayVecCopy::from([0, 1, 2, 3]);
/// assert_eq!([0, 1, 2, 3], v.take().into_inner().unwrap());
Expand Down Expand Up @@ -796,7 +796,7 @@ impl<T: Copy, const CAP: usize> DerefMut for ArrayVecCopy<T, CAP> {
/// Create an `ArrayVecCopy` from an array.
///
/// ```
/// use arrayvec::ArrayVecCopy;
/// use arrayvec::copy::ArrayVecCopy;
///
/// let mut array = ArrayVecCopy::from([1, 2, 3]);
/// assert_eq!(array.len(), 3);
Expand All @@ -821,7 +821,7 @@ impl<T: Copy, const CAP: usize> From<[T; CAP]> for ArrayVecCopy<T, CAP> {
/// fit.
///
/// ```
/// use arrayvec::ArrayVecCopy;
/// use arrayvec::copy::ArrayVecCopy;
/// use std::convert::TryInto as _;
///
/// let array: ArrayVecCopy<_, 4> = (&[1, 2, 3] as &[_]).try_into().unwrap();
Expand All @@ -848,7 +848,7 @@ impl<T: Copy, const CAP: usize> std::convert::TryFrom<&[T]> for ArrayVecCopy<T,
/// Iterate the `ArrayVecCopy` with references to each element.
///
/// ```
/// use arrayvec::ArrayVecCopy;
/// use arrayvec::copy::ArrayVecCopy;
///
/// let array = ArrayVecCopy::from([1, 2, 3]);
///
Expand All @@ -865,7 +865,7 @@ impl<'a, T: Copy + 'a, const CAP: usize> IntoIterator for &'a ArrayVecCopy<T, CA
/// Iterate the `ArrayVecCopy` with mutable references to each element.
///
/// ```
/// use arrayvec::ArrayVecCopy;
/// use arrayvec::copy::ArrayVecCopy;
///
/// let mut array = ArrayVecCopy::from([1, 2, 3]);
///
Expand All @@ -884,7 +884,7 @@ impl<'a, T: Copy + 'a, const CAP: usize> IntoIterator for &'a mut ArrayVecCopy<T
/// The vector is consumed by this operation.
///
/// ```
/// use arrayvec::ArrayVecCopy;
/// use arrayvec::copy::ArrayVecCopy;
///
/// for elt in ArrayVecCopy::from([1, 2, 3]) {
/// // ...
Expand All @@ -906,7 +906,7 @@ impl<T: Copy, const CAP: usize> IntoIterator for ArrayVecCopy<T, CAP> {
/// Cannot ensure that previous moves of the `ArrayVecCopy` did not leave values on the stack.
///
/// ```
/// use arrayvec::ArrayVecCopy;
/// use arrayvec::copy::ArrayVecCopy;
/// use zeroize::Zeroize;
/// let mut array = ArrayVecCopy::from([1, 2, 3]);
/// array.zeroize();
Expand Down
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,9 @@ mod errors;
mod utils;

pub mod copy {
pub use crate::arrayvec_copy::{Drain, IntoIter};
pub use crate::arrayvec_copy::{ArrayVecCopy, Drain, IntoIter};
}

pub use crate::arrayvec_copy::ArrayVecCopy;
pub use crate::array_string::ArrayString;
pub use crate::errors::CapacityError;

Expand Down

0 comments on commit 9c19f78

Please sign in to comment.