Merge rust-bitcoin/rust-bitcoin#2512: internals: Implement Default for ArrayVec

a55e78a28d internals: Implement Default for ArrayVec (Tobin C. Harding)

Pull request description:

  In an unrelated PR CI run we got the following error:

  ```
  error: you should consider adding a `Default` implementation for `ArrayVec<T, CAP>`
  ```

  I did not bother to dig any deeper since this seems like a reasonable suggestion by the compiler since we provide a `new` function that takes zero arguments.

  Add a `Default` implementation to `ArrayVec`.

ACKs for top commit:
  apoelstra:
    ACK a55e78a28d
  Kixunil:
    ACK a55e78a28d

Tree-SHA512: 85b8248ca3b6d098eeb65042d89f69fc359ef1d167c52abf321b5a6597c0a8d44cd7383668b959c2082156214a47a61478d725431718c41f23f3ca48fb274342
This commit is contained in:
Andrew Poelstra 2024-02-28 18:55:15 +00:00
commit 1f3d05ea98
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
1 changed files with 4 additions and 0 deletions

View File

@ -95,6 +95,10 @@ mod safety_boundary {
} }
} }
impl<T: Copy, const CAP: usize> Default for ArrayVec<T, CAP> {
fn default() -> Self { Self::new() }
}
/// Clones the value *faster* than using `Copy`. /// Clones the value *faster* than using `Copy`.
/// ///
/// Because we avoid copying the uninitialized part of the array this copies the value faster than /// Because we avoid copying the uninitialized part of the array this copies the value faster than