Repository: bluss/arrayvec (rust)

Issue:
[ArrayString] Infallible constructor to fill inner array
Some libraries like `hex` or `bs58` expect a pre-filled buffer to operate on but `ArrayString` does not have an infallible constructor to create a fully filled inner array with "whatever".

For example, the following made use of `from_byte_string` to make everything work as expected:

```rust
let mut buffer = ArrayString::from_byte_string(&[b' '; SOME_LEN]).unwrap();
let len = bs58::encode(some_data).into(&mut buffer[..]).unwrap_or_default();
buffer.truncate(len);
```

So do you mind me providing a PR to create something like `ArrayString::new_filled()`?

Pull request description:
Add `zero_filled` constructor
Fixes #196 

Patch:
diff --git a/src/array_string.rs b/src/array_string.rs
index a044cb5..639fe74 100644
--- a/src/array_string.rs
+++ b/src/array_string.rs
@@ -129,6 +129,28 @@ impl<const CAP: usize> ArrayString<CAP>
         Ok(vec)
     }
 
+    /// Create a new `ArrayString` value fully filled with ASCII NULL characters (`\0`). Useful
+    /// to be used as a buffer to collect external data or as a buffer for intermediate processing.
+    ///
+    /// ```
+    /// use arrayvec::ArrayString;
+    ///
+    /// let string = ArrayString::<16>::zero_filled();
+    /// assert_eq!(string.len(), 16);
+    /// ```
+    #[inline]
+    pub fn zero_filled() -> Self {
+        assert_capacity_limit!(CAP);
+        // SAFETY: `assert_capacity_limit` asserts that `len` won't overflow and
+        // `zeroed` fully fills the array with nulls.
+        unsafe {
+            ArrayString {
+                xs: MaybeUninit::zeroed().assume_init(),
+                len: CAP as _
+            }
+        }
+    }
+
     /// Return the capacity of the `ArrayString`.
     ///
     /// ```


Test patch:
diff --git a/tests/tests.rs b/tests/tests.rs
index 26d09ae..2f8a5ef 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -773,7 +773,6 @@ fn test_arrayvec_const_constructible() {
     assert_eq!(var[..], [vec![3, 5, 8]]);
 }
 
-
 #[test]
 fn test_arraystring_const_constructible() {
     const AS: ArrayString<10> = ArrayString::new_const();
@@ -786,3 +785,9 @@ fn test_arraystring_const_constructible() {
 }
 
 
+#[test]
+fn test_arraystring_zero_filled_has_some_sanity_checks() {
+    let string = ArrayString::<4>::zero_filled();
+    assert_eq!(string.as_str(), "\0\0\0\0");
+    assert_eq!(string.len(), 4);
+}
\ No newline at end of file