From 3ea6cb5245295e8c977066d645b6602f34471d81 Mon Sep 17 00:00:00 2001 From: ScriptAndCompile Date: Thu, 13 Jun 2024 12:40:44 -0700 Subject: [PATCH] Added docs for new and default. --- src/data_structures/binary_search_tree.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/data_structures/binary_search_tree.rs b/src/data_structures/binary_search_tree.rs index de0df34..3a9b898 100644 --- a/src/data_structures/binary_search_tree.rs +++ b/src/data_structures/binary_search_tree.rs @@ -47,6 +47,17 @@ where T: Ord, { + /// Create a new, empty `BinarySearchTree`. + /// + /// # Examples + /// + /// ```rust + /// use rust_algorithms::data_structures::BinarySearchTree; + /// + /// let tree: BinarySearchTree = BinarySearchTree::default(); + /// + /// assert!(tree.is_empty()); + /// ``` fn default() -> Self { Self::new() } @@ -57,6 +68,17 @@ where T: Ord, { + /// Create a new, empty `BinarySearchTree`. + /// + /// # Examples + /// + /// ```rust + /// use rust_algorithms::data_structures::BinarySearchTree; + /// + /// let tree: BinarySearchTree = BinarySearchTree::new(); + /// + /// assert!(tree.is_empty()); + /// ``` pub fn new() -> BinarySearchTree { BinarySearchTree { value: None,