@@ -108,7 +108,7 @@ impl<T, const CAP: usize> ArrayVec<T, CAP> {
108
108
/// assert_eq!(array.len(), 2);
109
109
/// ```
110
110
#[ inline( always) ]
111
- pub fn len ( & self ) -> usize { self . len as usize }
111
+ pub const fn len ( & self ) -> usize { self . len as usize }
112
112
113
113
/// Returns whether the `ArrayVec` is empty.
114
114
///
@@ -120,7 +120,7 @@ impl<T, const CAP: usize> ArrayVec<T, CAP> {
120
120
/// assert_eq!(array.is_empty(), true);
121
121
/// ```
122
122
#[ inline]
123
- pub fn is_empty ( & self ) -> bool { self . len ( ) == 0 }
123
+ pub const fn is_empty ( & self ) -> bool { self . len ( ) == 0 }
124
124
125
125
/// Return the capacity of the `ArrayVec`.
126
126
///
@@ -131,7 +131,7 @@ impl<T, const CAP: usize> ArrayVec<T, CAP> {
131
131
/// assert_eq!(array.capacity(), 3);
132
132
/// ```
133
133
#[ inline( always) ]
134
- pub fn capacity ( & self ) -> usize { CAP }
134
+ pub const fn capacity ( & self ) -> usize { CAP }
135
135
136
136
/// Return true if the `ArrayVec` is completely filled to its capacity, false otherwise.
137
137
///
@@ -143,7 +143,7 @@ impl<T, const CAP: usize> ArrayVec<T, CAP> {
143
143
/// array.push(1);
144
144
/// assert!(array.is_full());
145
145
/// ```
146
- pub fn is_full ( & self ) -> bool { self . len ( ) == self . capacity ( ) }
146
+ pub const fn is_full ( & self ) -> bool { self . len ( ) == self . capacity ( ) }
147
147
148
148
/// Returns the capacity left in the `ArrayVec`.
149
149
///
@@ -154,7 +154,7 @@ impl<T, const CAP: usize> ArrayVec<T, CAP> {
154
154
/// array.pop();
155
155
/// assert_eq!(array.remaining_capacity(), 1);
156
156
/// ```
157
- pub fn remaining_capacity ( & self ) -> usize {
157
+ pub const fn remaining_capacity ( & self ) -> usize {
158
158
self . capacity ( ) - self . len ( )
159
159
}
160
160
0 commit comments