We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e5b3c9b commit 481f930Copy full SHA for 481f930
src/array_string.rs
@@ -152,6 +152,19 @@ impl<const CAP: usize> ArrayString<CAP>
152
/// ```
153
pub fn is_full(&self) -> bool { self.len() == self.capacity() }
154
155
+ /// Returns the capacity left in the `ArrayString`.
156
+ ///
157
+ /// ```
158
+ /// use arrayvec::ArrayString;
159
160
+ /// let mut string = ArrayString::<3>::from("abc").unwrap();
161
+ /// string.pop();
162
+ /// assert_eq!(string.remaining_capacity(), 1);
163
164
+ pub const fn remaining_capacity(&self) -> usize {
165
+ self.capacity() - self.len()
166
+ }
167
+
168
/// Adds the given char to the end of the string.
169
///
170
/// ***Panics*** if the backing array is not large enough to fit the additional char.
0 commit comments