pub fn last(&self) -> Option<&T> {
        let len = self.items.len();

        if len == 0 {
            None
        } else if len < (self.len_cap as usize) {
            Some(&self.items[len - 1])
        } else {
            let index = (self.len_cap + self.head_index - 1) % (self.len_cap);
            Some(&self.items[index as usize])
        }
    }
/// Returns the last element, or `None` if it is empty.
///
/// # Examples
/// ```
/// # use financial_primitives::capvec::CapVec;
/// let mut items = CapVec::<u64>::new(2);
/// assert_eq!(items.last(), None);
/// ```
/// ```
/// # use financial_primitives::capvec::CapVec;
/// let mut items = CapVec::<u64>::new(2);
/// items.push(1);
/// items.push(2);
/// items.push(3);
/// assert_eq!(items.last(), Some(&3));
/// ```
Returns the last element, or `None` if it is empty.
Returns the last element or ` None ` if it is empty .
pub fn last(&self) -> Option<&T> {
        let len = self.items.len();
        if len == 0 {
            None
        } else if len < (self.len_cap as usize) {
            Some(&self.items[len - 1])
        } else {
            let index = (self.len_cap + self.head_index - 1) % (self.len_cap);
            Some(&self.items[index as usize])
        }
    }
pub fn last ( & self ) -> Option < & T > { let len = self . items . len ( ) ; if len == 0 { None } else if len < ( self . len_cap as usize ) { Some ( & self . items [ len - 1 ] ) } else { let index = ( self . len_cap + self . head_index - 1 ) % ( self . len_cap ) ; Some ( & self . items [ index as usize ] ) } }
Returns the last element, or `None` if it is empty.
Returns the last element or ` None ` if it is empty .
&self
&self
examples
None
use financial_primitives::capvec::capvec;
None
use financial_primitives::capvec::capvec;
None