Skip to content

Commit

Permalink
Added docs for new and default.
Browse files Browse the repository at this point in the history
  • Loading branch information
scriptandcompile committed Jun 13, 2024
1 parent d7191ef commit 3ea6cb5
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/data_structures/binary_search_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ where
T: Ord,
{

/// Create a new, empty `BinarySearchTree`.
///
/// # Examples
///
/// ```rust
/// use rust_algorithms::data_structures::BinarySearchTree;
///
/// let tree: BinarySearchTree<i32> = BinarySearchTree::default();
///
/// assert!(tree.is_empty());
/// ```
fn default() -> Self {
Self::new()
}
Expand All @@ -57,6 +68,17 @@ where
T: Ord,
{

/// Create a new, empty `BinarySearchTree`.
///
/// # Examples
///
/// ```rust
/// use rust_algorithms::data_structures::BinarySearchTree;
///
/// let tree: BinarySearchTree<i32> = BinarySearchTree::new();
///
/// assert!(tree.is_empty());
/// ```
pub fn new() -> BinarySearchTree<T> {
BinarySearchTree {
value: None,
Expand Down

0 comments on commit 3ea6cb5

Please sign in to comment.