From 01dbaae83feed995e7ce56a60ceaaada34bde5c6 Mon Sep 17 00:00:00 2001 From: martial-plains <41553768+martial-plains@users.noreply.github.com> Date: Sat, 31 Aug 2024 13:32:38 -0400 Subject: [PATCH] fix: fix doc comments --- src/math/greatest_common_divisor.rs | 37 ----------------------------- src/strings/capitalize.rs | 2 +- src/strings/jaro_winkler.rs | 4 ++-- src/strings/remove_duplicates.rs | 4 ++-- 4 files changed, 5 insertions(+), 42 deletions(-) diff --git a/src/math/greatest_common_divisor.rs b/src/math/greatest_common_divisor.rs index 8bb6255..4599533 100644 --- a/src/math/greatest_common_divisor.rs +++ b/src/math/greatest_common_divisor.rs @@ -46,43 +46,6 @@ where gcd_cmp(a, b) } -/// Computes the greatest common divisor (GCD) of two nonnegative integers `p` and `q`. -/// -/// # Examples -/// -/// ``` -/// use algoritmer::math::gcd_cmp; -/// use num::Integer; -/// -/// let p: u32 = 24; -/// let q: u32 = 18; -/// let gcd = gcd_cmp(p, q); -/// assert_eq!(gcd, 6); -/// ``` -/// -/// # Explanation -/// -/// The function recursively applies the Euclidean algorithm to calculate the GCD. -/// -/// 1. In the first step, we check if `q` is zero. If it is, the GCD is `p`, so we return `p`. -/// -/// 2. If `q` is not zero, we compute the remainder `r` when `p` is divided by `q` using the `%` operator. -/// -/// 3. We then recursively call the `gcd_cmp` function with `q` as the new value of `p` and `r` as the new value of `q`. -/// -/// 4. Steps 1-3 are repeated until `q` becomes zero. At this point, the function returns `p`, which is the GCD of the original `p` and `q`. -/// -/// In the provided example, `p` is 24 and `q` is 18. -/// -/// 1. Since `q` is not zero, we calculate `r` as the remainder of `p` divided by `q`, which is 6. -/// -/// 2. We then call `gcd_cmp` with `q` (18) as the new `p` and `r` (6) as the new `q`. -/// -/// 3. Since `q` is still not zero, we calculate `r` as the remainder of `p` (18) divided by `q` (6), which is 0. -/// -/// 4. Now, `q` is zero, so we return `p` (6) as the GCD of the original `p` (24) and `q` (18). -/// -/// Therefore, the GCD of 24 and 18 is 6. fn gcd_cmp(p: T, q: T) -> T where T: num::Unsigned + Copy, diff --git a/src/strings/capitalize.rs b/src/strings/capitalize.rs index 0e33812..f7d119f 100644 --- a/src/strings/capitalize.rs +++ b/src/strings/capitalize.rs @@ -18,7 +18,7 @@ pub trait Capitalizable { /// use algoritmer::strings::Capitalizable; /// /// let text = "hello world"; - /// let capitalized = text.capitalize(); + /// let capitalized = text.capitalized(); /// assert_eq!(capitalized, "Hello world"); /// ``` fn capitalized(&self) -> String; diff --git a/src/strings/jaro_winkler.rs b/src/strings/jaro_winkler.rs index 82ca058..62ad62a 100644 --- a/src/strings/jaro_winkler.rs +++ b/src/strings/jaro_winkler.rs @@ -18,7 +18,7 @@ use alloc::{ /// /// let str1 = "martha"; /// let str2 = "marhta"; -/// println!("{}", str1.jaro_winkler(&str2)); +/// println!("{}", str1.jaro_winklered(&str2)); /// ``` /// /// # References @@ -42,7 +42,7 @@ pub trait JaroWinkler { /// /// let str1 = "martha"; /// let str2 = "marhta"; - /// assert_eq!(str1.jaro_winkler(&str2), 0.9611111111111111); + /// assert_eq!(str1.jaro_winklered(&str2), 0.9611111111111111); /// ``` fn jaro_winklered(&self, other: &str) -> f64; } diff --git a/src/strings/remove_duplicates.rs b/src/strings/remove_duplicates.rs index 0f61a1e..5b34102 100644 --- a/src/strings/remove_duplicates.rs +++ b/src/strings/remove_duplicates.rs @@ -24,11 +24,11 @@ where /// use algoritmer::strings::RemoveDuplicates; /// /// let text = "hello,world,hello,rust"; - /// let result = text.remove_duplicates(","); + /// let result = text.removed_duplicates(","); /// assert_eq!(result, "hello,world,rust"); /// /// let text_space = "hello world hello rust"; - /// let result_space = text_space.remove_duplicates(" "); + /// let result_space = text_space.removed_duplicates(" "); /// assert_eq!(result_space, "hello world rust"); /// ``` fn removed_duplicates(&self, separator: P) -> String;