From d5a621e1fc976303738dcdfac376d88fbaae015d Mon Sep 17 00:00:00 2001 From: weifanglab Date: Mon, 13 Jul 2026 23:37:53 +0800 Subject: [PATCH] chore: fix some comments to improve readability Signed-off-by: weifanglab --- src/lib.rs | 6 +++--- src/primitives/correction.rs | 4 ++-- src/primitives/decode.rs | 8 ++++---- src/primitives/lfsr.rs | 4 ++-- src/primitives/polynomial.rs | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index ff79d7b8..aed42d75 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -314,7 +314,7 @@ pub fn encode_lower_to_fmt( Ok(()) } -/// Encodes `data` to a writer ([`fmt::Write`]) as a uppercase bech32 encoded string. +/// Encodes `data` to a writer ([`fmt::Write`]) as an uppercase bech32 encoded string. /// /// Encoded string will be prefixed with the `hrp` and have a checksum appended as specified by the /// `Ck` algorithm (`NoChecksum` to exclude checksum all together). @@ -399,7 +399,7 @@ pub fn encode_lower_to_writer( Ok(()) } -/// Encodes `data` to a writer ([`io::Write`]) as a uppercase bech32 encoded string. +/// Encodes `data` to a writer ([`io::Write`]) as an uppercase bech32 encoded string. /// /// Encoded string will be prefixed with the `hrp` and have a checksum appended as specified by the /// `Ck` algorithm (`NoChecksum` to exclude checksum all together). @@ -757,7 +757,7 @@ mod tests { #[test] fn can_decode_segwit_too_long_string() { - // A 91 character long string, greater than the segwit enforced maximum of 90. + // A 91 character long string, greater than the segwit enforced maximum of 90. let s = "abcd1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqrw9z3s"; assert!(decode(s).is_ok()); } diff --git a/src/primitives/correction.rs b/src/primitives/correction.rs index 21374c4e..42bee699 100644 --- a/src/primitives/correction.rs +++ b/src/primitives/correction.rs @@ -139,7 +139,7 @@ pub struct Corrector { impl Corrector { /// A bound on the number of errors and erasures (errors with known location) - /// can be corrected by this corrector. + /// that can be corrected by this corrector. /// /// Returns N such that, given E errors and X erasures, correction is possible /// iff 2E + X <= N. @@ -288,7 +288,7 @@ impl Iterator for ErrorIterator<'_, Ck> { // (a^i)^(c - 1)) locator_derivative(a^-i) // // where here a is `Ck::ROOT_GENERATOR`, c is the first element of the range - // `Ck::ROOT_EXPONENTS`, and both evalutor and locator_derivative are polynomials + // `Ck::ROOT_EXPONENTS`, and both evaluator and locator_derivative are polynomials // which are computed when constructing the ErrorIterator. let a_i = self.a.powi(neg_i as i64); diff --git a/src/primitives/decode.rs b/src/primitives/decode.rs index 4eac9c90..abd41d6a 100644 --- a/src/primitives/decode.rs +++ b/src/primitives/decode.rs @@ -109,7 +109,7 @@ const SEP: char = '1'; /// } else if unchecked.has_valid_checksum::() { /// // Remove the checksum and do something with the data as above. /// } else { -/// // Checksum is not valid for either the bech32 or bech32 checksum algorithms. +/// // Checksum is not valid for either the bech32 or bech32m checksum algorithms. /// } /// ``` #[derive(Debug)] @@ -125,7 +125,7 @@ pub struct UncheckedHrpstring<'s> { } impl<'s> UncheckedHrpstring<'s> { - /// Parses an bech32 encode string and constructs a [`UncheckedHrpstring`] object. + /// Parses an bech32 encode string and constructs an [`UncheckedHrpstring`] object. /// /// Checks for valid ASCII values, does not validate the checksum. #[inline] @@ -279,7 +279,7 @@ impl<'s> UncheckedHrpstring<'s> { Ok(()) } - /// Removes the checksum for the `Ck` algorithm and returns an [`CheckedHrpstring`]. + /// Removes the checksum for the `Ck` algorithm and returns a [`CheckedHrpstring`]. /// /// Data must be valid (ie, first call `has_valid_checksum` or `validate_checksum()`). This /// function is typically paired with `has_valid_checksum` when validating against multiple @@ -329,7 +329,7 @@ pub struct CheckedHrpstring<'s> { hrp: Hrp, /// This is ASCII byte values of the parsed string, guaranteed to be valid bech32 characters. /// - /// The characters after the '1' separator and the before the checksum. + /// The characters after the '1' separator and before the checksum. ascii: &'s [u8], /// The length of the parsed hrpstring. hrpstring_length: usize, // Guaranteed to be <= CK::CODE_LENGTH diff --git a/src/primitives/lfsr.rs b/src/primitives/lfsr.rs index 5b64597b..a0c81986 100644 --- a/src/primitives/lfsr.rs +++ b/src/primitives/lfsr.rs @@ -235,7 +235,7 @@ mod tests { // the "2L <= N" path with x != L. LfsrIter::berlekamp_massey(&[Fe32::Q, Fe32::Y, Fe32::H]).take(10).count(); - // Hits the the "2L <= N" path with x != L, without overflowing subtraction + // Hits the "2L <= N" path with x != L, without overflowing subtraction // as in the above vector. let sequence: Vec<_> = LfsrIter::berlekamp_massey(&[Fe32::Y, Fe32::H, Fe32::Q, Fe32::Q]).take(10).collect(); @@ -254,7 +254,7 @@ mod tests { // This vector specifically exercises the Step 5 update path // Step 5 runs when old_conn.len() + x > conn.len() // where old_conn is multiplied into the update term - // replacing '*' with '/' there changes output. + // replacing '*' with '/' there changes output. let step5_sequence: Vec<_> = LfsrIter::berlekamp_massey(&[Fe32::A, Fe32::C, Fe32::A, Fe32::Y, Fe32::A]) .take(4) diff --git a/src/primitives/polynomial.rs b/src/primitives/polynomial.rs index 08e110ca..fd485eb4 100644 --- a/src/primitives/polynomial.rs +++ b/src/primitives/polynomial.rs @@ -256,7 +256,7 @@ impl Polynomial { // search them. In practice this doesn't matter because we have // such a small number of roots (it may actually be faster than // using a hashset) and because the root-finding takes such a - // long time that noboby can use this method in a loop anyway. + // long time that nobody can use this method in a loop anyway. let mut len = 2; while let Ok(k) = roots[..].binary_search(&((r2 + ratio) % E::MULTIPLICATIVE_ORDER)) {