Skip to content

Commit

Permalink
fix: fix doc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
martial-plains committed Aug 31, 2024
1 parent 2c26c56 commit 01dbaae
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 42 deletions.
37 changes: 0 additions & 37 deletions src/math/greatest_common_divisor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>(p: T, q: T) -> T
where
T: num::Unsigned + Copy,
Expand Down
2 changes: 1 addition & 1 deletion src/strings/capitalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/strings/jaro_winkler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use alloc::{
///
/// let str1 = "martha";
/// let str2 = "marhta";
/// println!("{}", str1.jaro_winkler(&str2));
/// println!("{}", str1.jaro_winklered(&str2));
/// ```
///
/// # References
Expand All @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/strings/remove_duplicates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 01dbaae

Please sign in to comment.