Add is_full predicate methods

This commit is contained in:
Jake Goulding
2016-05-28 10:00:38 -04:00
parent a41ecc0a29
commit b0bf84b201
2 changed files with 24 additions and 0 deletions
+12
View File
@@ -77,6 +77,18 @@ impl<A: Array<Item=u8>> ArrayString<A> {
#[inline]
pub fn capacity(&self) -> usize { A::capacity() }
/// Return if the `ArrayString` is completely filled.
///
/// ```
/// use arrayvec::ArrayString;
///
/// let mut string = ArrayString::<[_; 1]>::new();
/// assert!(!string.is_full());
/// string.push_str("A");
/// assert!(string.is_full());
/// ```
pub fn is_full(&self) -> bool { self.len() == self.capacity() }
/// Adds the given char to the end of the string.
///
/// Returns `Ok` if the push succeeds.