Add is_full predicate methods
This commit is contained in:
@@ -77,6 +77,18 @@ impl<A: Array<Item=u8>> ArrayString<A> {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn capacity(&self) -> usize { A::capacity() }
|
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.
|
/// Adds the given char to the end of the string.
|
||||||
///
|
///
|
||||||
/// Returns `Ok` if the push succeeds.
|
/// Returns `Ok` if the push succeeds.
|
||||||
|
|||||||
+12
@@ -125,6 +125,18 @@ impl<A: Array> ArrayVec<A> {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn capacity(&self) -> usize { A::capacity() }
|
pub fn capacity(&self) -> usize { A::capacity() }
|
||||||
|
|
||||||
|
/// Return if the `ArrayVec` is completely filled.
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// use arrayvec::ArrayVec;
|
||||||
|
///
|
||||||
|
/// let mut array = ArrayVec::<[_; 1]>::new();
|
||||||
|
/// assert!(!array.is_full());
|
||||||
|
/// array.push(1);
|
||||||
|
/// assert!(array.is_full());
|
||||||
|
/// ```
|
||||||
|
pub fn is_full(&self) -> bool { self.len() == self.capacity() }
|
||||||
|
|
||||||
/// Push `element` to the end of the vector.
|
/// Push `element` to the end of the vector.
|
||||||
///
|
///
|
||||||
/// Return `None` if the push succeeds, or and return `Some(` *element* `)`
|
/// Return `None` if the push succeeds, or and return `Some(` *element* `)`
|
||||||
|
|||||||
Reference in New Issue
Block a user