Add is_empty method for ArrayVec and ArrayString
This commit is contained in:
@@ -71,6 +71,10 @@ impl<A> ArrayString<A>
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn len(&self) -> usize { self.len.to_usize() }
|
pub fn len(&self) -> usize { self.len.to_usize() }
|
||||||
|
|
||||||
|
/// Returns whether the string is empty.
|
||||||
|
#[inline]
|
||||||
|
pub fn is_empty(&self) -> bool { self.len() == 0 }
|
||||||
|
|
||||||
/// Create a new `ArrayString` from a `str`.
|
/// Create a new `ArrayString` from a `str`.
|
||||||
///
|
///
|
||||||
/// Capacity is inferred from the type parameter.
|
/// Capacity is inferred from the type parameter.
|
||||||
|
|||||||
+12
@@ -126,6 +126,18 @@ impl<A: Array> ArrayVec<A> {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn len(&self) -> usize { self.len.to_usize() }
|
pub fn len(&self) -> usize { self.len.to_usize() }
|
||||||
|
|
||||||
|
/// Returns whether the `ArrayVec` is empty.
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// use arrayvec::ArrayVec;
|
||||||
|
///
|
||||||
|
/// let mut array = ArrayVec::from([1]);
|
||||||
|
/// array.pop();
|
||||||
|
/// assert_eq!(array.is_empty(), true);
|
||||||
|
/// ```
|
||||||
|
#[inline]
|
||||||
|
pub fn is_empty(&self) -> bool { self.len() == 0 }
|
||||||
|
|
||||||
/// Return the capacity of the `ArrayVec`.
|
/// Return the capacity of the `ArrayVec`.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
|
|||||||
Reference in New Issue
Block a user