From 5e3d454fd85d6458bd9118ccce712823e09ffdd1 Mon Sep 17 00:00:00 2001 From: Aurelia Date: Tue, 1 Aug 2023 15:17:15 +0200 Subject: [PATCH] Typos and formatting. --- src/gtid_set.rs | 15 +++++++++------ src/lib.rs | 20 ++++++++++---------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/gtid_set.rs b/src/gtid_set.rs index d866835..e99792f 100644 --- a/src/gtid_set.rs +++ b/src/gtid_set.rs @@ -1,6 +1,6 @@ // Author Axel Viala -// Done on free time inspired a lot by pymysqlreplication own implementation. -// Licence MIT + APACHE 2. +// Done on free time inspired a lot by pymysql replication own implementation. +// License MIT + APACHE 2. use crate::{Gtid, GtidError}; use std::iter::Iterator; @@ -43,7 +43,7 @@ impl From<&[Gtid]> for GtidSet { impl GtidSet { pub fn include_gtid(&mut self, gtid: &Gtid) { match self.gtids.get_mut(>id.sid) { - // Unwraping is safe we work on the same sid + // Unwrapping is safe we work on the same sid Some(g) => g.include_transactions(gtid).unwrap(), None => { self.gtids.insert(gtid.sid, gtid.clone()); @@ -53,7 +53,7 @@ impl GtidSet { pub fn include_gtid_consume(&mut self, gtid: Gtid) { match self.gtids.get_mut(>id.sid) { - // Unwraping is safe we work on the same sid + // Unwrapping is safe we work on the same sid Some(g) => g.include_transactions(>id).unwrap(), None => { self.gtids.insert(gtid.sid, gtid); @@ -91,7 +91,7 @@ impl GtidSet { /// - `n_sid`: u64 is the number of Gtid to read /// - `Gtid`: `n_sid` * `Gtid_encoded_size` times See [Gtid] documentation for details. /// ```txt - /// Alligned on u64 bit + /// Aligned on u64 bit /// +-+-+-+-+-+-+-+-+-+-+ /// | n_gtid u64 | /// | | @@ -139,7 +139,10 @@ impl GtidSet { /// Iterator over raw values useful for bridging with `Sid` type in mysql crate. pub fn into_raw(self) -> Vec<([u8; 16], Vec<(u64, u64)>)> { - self.gtids.into_values().map(|gtid| gtid.into_raw()).collect() + self.gtids + .into_values() + .map(|gtid| gtid.into_raw()) + .collect() } } diff --git a/src/lib.rs b/src/lib.rs index 18e5787..4601909 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -54,7 +54,7 @@ impl Gtid { String::from_utf8_lossy(&sid[..]).to_string() } - /// Unsable may be removed. + /// Unstable may be removed. pub fn raw_gtid_unchecked(sid: [u8; 36]) -> Result { let sid = parse_uuid(&sid)?; @@ -115,7 +115,7 @@ impl Gtid { } if self.intervals.iter().any(|x| overlap(x, interval)) { - return Err(GtidError::OverlapingInterval); + return Err(GtidError::OverlappingInterval); } self.add_interval_unchecked(interval); @@ -144,7 +144,7 @@ impl Gtid { /// Remove an interval from intervals. /// - /// Does not check for Zero in internval, interval badly ordered or overlap. + /// Does not check for Zero in interval, interval badly ordered or overlap. /// Assume interval is well formed. pub fn sub_interval(&mut self, interval: &(u64, u64)) -> Result<(), GtidError> { if interval.0 == 0 || interval.1 == 0 { @@ -208,7 +208,7 @@ impl Gtid { /// /// For binary format description see [Gtid::serialize] /// - /// Known issue: sid need to be validated and not accepted blindy. + /// Known issue: sid need to be validated and not accepted blindly. pub fn parse(reader: &mut R) -> io::Result { // Reading and decoding SID let mut sid = [0u8; 16]; @@ -267,7 +267,7 @@ impl Gtid { // Encode in little endian the len writer.write_all(&(self.intervals.len() as u64).to_le_bytes())?; - // Encode the intervals itselfs in little endian (start, stop) + // Encode the intervals themselves in little endian (start, stop) for (start, end) in self.intervals.iter() { writer.write_all(&start.to_le_bytes())?; writer.write_all(&end.to_le_bytes())?; @@ -305,7 +305,7 @@ pub enum GtidError { /// SID or Interval is in invalid form ParseError, /// Intervals overlaps - OverlapingInterval, + OverlappingInterval, /// Interval must be Ordered (sorted) IntervalBadlyOrdered, /// Interval shall not contain 0 @@ -323,7 +323,7 @@ impl Display for GtidError { } /// Parse a human-generated interval, end value will be incremented to match mysql internals. -/// Exemple if given `1,2` will output `(1, 3)`. +/// Example if given `1,2` will output `(1, 3)`. /// /// ```ignore /// # use crate::parse_interval; @@ -370,7 +370,7 @@ impl TryFrom<&str> for Gtid { .windows(2) .any(|tuples| overlap(&tuples[0], &tuples[1])) { - return Err(GtidError::OverlapingInterval); + return Err(GtidError::OverlappingInterval); } Ok(Gtid { sid, intervals }) } @@ -604,7 +604,7 @@ mod test { assert_eq!( gtid.add_interval(&(50, 51)), - Err(GtidError::OverlapingInterval) + Err(GtidError::OverlappingInterval) ); assert_eq!(gtid.intervals, [(1, 57)]); @@ -804,6 +804,6 @@ mod test { assert_eq!(Gtid::try_from(gtids), Err(GtidError::IntervalBadlyOrdered)); let gtids = "57b70f4e-20d3-11e5-a393-4a63946f7eac:1-5:2-3"; - assert_eq!(Gtid::try_from(gtids), Err(GtidError::OverlapingInterval)); + assert_eq!(Gtid::try_from(gtids), Err(GtidError::OverlappingInterval)); } }