villa01-data-structures 0.2.0

Personal crate of me trying to implement data structures and algorithms in Rust.
Documentation
use super::DoublyLinkedList;

impl<T> DoublyLinkedList<T> {
    /// Checks if the `DoublyLinkedList` is empty.
    ///
    /// # Returns
    /// `true` if the list has no elements, and `false` otherwise
    ///
    /// # Examples
    /// ```
    /// use villa01_data_structures::doubly_linked_list::DoublyLinkedList;
    ///
    /// let empty_list: DoublyLinkedList<i32> = DoublyLinkedList::new();
    /// assert!(empty_list.is_empty());
    ///
    /// let list: DoublyLinkedList<i32> = DoublyLinkedList::with_value(69);
    /// assert!(!list.is_empty());
    /// ```
    pub fn is_empty(&self) -> bool {
        self.len() == 0 && self.head.is_none()
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_is_empty() {
        let mut list: DoublyLinkedList<usize> = DoublyLinkedList::new();
        assert!(list.is_empty());
        list.insert_at_beginning(1);
        assert!(!list.is_empty());
    }
}