From eb3914009f76afe9649abbfdc32ffb2a3f79ba06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wilhelm=20=C3=85gren?= Date: Fri, 25 Jul 2025 10:37:07 +0200 Subject: [PATCH 1/3] fix: rustdocs strict lifetime checking --- src/source.rs | 36 ++++++++---------------------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/src/source.rs b/src/source.rs index 1a75552..c64d24a 100644 --- a/src/source.rs +++ b/src/source.rs @@ -48,7 +48,9 @@ impl Source for &str { type Symbol = char; type Buffer = String; type Output = String; - type Slice<'a> = Self; + type Slice<'a> = Self + where + Self: 'a; /// Truncates the &str to match the specified `width` according to the specified alignment /// `mode`. @@ -98,8 +100,6 @@ impl Source for &str { /// Pads or truncates the &str to match the specified `width` according to the specified /// alignment `mode`. /// - /// See [`truncate_to_fit`] for details on how truncating is performed. - /// /// If the &str is longer than `width` (in utf8 chars), it will be truncated. /// /// If the &str is shorter than `width`, it will be padded using the `symbol`. @@ -121,7 +121,6 @@ impl Source for &str { /// assert_eq!(18, o2.capacity()); // these utf8 chars use more bytes :) /// assert_eq!(18, o2.len()); /// ``` - /// [`truncate_to_fit`]: Self::truncate_to_fit fn pad(&self, width: usize, mode: Alignment, symbol: Self::Symbol) -> Self::Output { let n_chars_original: usize = self.chars().count(); if width < n_chars_original { @@ -147,8 +146,6 @@ impl Source for &str { /// Pads or truncates the &str in-place to match the specified `width` according to the /// specified alignment `mode` by writing into the provided `buffer`. /// - /// See [`truncate_to_fit`] for details on how truncating is performed. - /// /// If the &str is longer than `width` (in utf8 chars), it will be truncated. /// /// If the &str is shorter than `width`, it will be padded using the `symbol`. @@ -175,7 +172,6 @@ impl Source for &str { /// assert_eq!(21, buf.capacity()); /// assert_eq!(21, buf.len()); /// ``` - /// [`truncate_to_fit`]: Self::truncate_to_fit fn pad_to_buffer( &self, width: usize, @@ -206,7 +202,9 @@ impl Source for String { type Symbol = char; type Buffer = Self; type Output = Self; - type Slice<'a> = &'a str; + type Slice<'a> = &'a str + where + Self: 'a; /// Truncates the string to match the specified `width` according to the specified alignment /// `mode`. @@ -255,8 +253,6 @@ impl Source for String { /// Pads or truncates the string to match the specified `width` according to the specified alignment `mode`. /// - /// See [`truncate_to_fit`] for details on how truncating is performed. - /// /// If the string is longer than `width` (in utf8 chars), it will be truncated. /// /// If the string is shorter than `width`, it will be padded using the `symbol`. @@ -272,7 +268,6 @@ impl Source for String { /// assert_eq!(18, o.capacity()); // 'ιΆ¨' is 3 bytes /// assert_eq!(18, o.len()); /// ``` - /// [`truncate_to_fit`]: Self::truncate_to_fit fn pad(&self, width: usize, mode: Alignment, symbol: Self::Symbol) -> Self::Output { let n_chars_original: usize = self.chars().count(); if width < n_chars_original { @@ -300,8 +295,6 @@ impl Source for String { /// Pads or truncates the string in-place to match the specified `width` according to the /// specified alignment `mode` by writing into the provided `buffer`. /// - /// See [`truncate_to_fit`] for details on how truncating is performed. - /// /// If the string is longer than `width` (in utf8 chars), it will be truncated. /// /// If the string is shorter than `width`, it will be padded using the `symbol`. @@ -328,7 +321,6 @@ impl Source for String { /// assert_eq!(10, buf.capacity()); /// assert_eq!(10, buf.len()); /// ``` - /// [`truncate_to_fit`]: Self::truncate_to_fit fn pad_to_buffer( &self, width: usize, @@ -365,7 +357,7 @@ where type Slice<'a> = &'a [T] where - T: 'a; + Self: 'a; /// Truncates the vector to match the specified `width` according to the specified alignment `mode`. /// - [`Alignment::Left`]: truncates from the right. @@ -385,8 +377,6 @@ where /// Pads or truncates the vector to match the specified `width` according to the specified alignment `mode`. /// - /// See [`truncate_to_fit`] for details on how truncating is performed. - /// /// If the vector is longer than `width` (in number of items), it will be truncated. /// /// If the vector is shorter than `width`, it will be padded using the `symbol`. @@ -402,7 +392,6 @@ where /// assert_eq!(5, o.capacity()); /// assert_eq!(5, o.len()); /// ``` - /// [`truncate_to_fit`]: Self::truncate_to_fit fn pad(&self, width: usize, mode: Alignment, symbol: Self::Symbol) -> Self::Output { if width < self.len() { return self.truncate_to_fit(width, mode).to_vec(); @@ -426,8 +415,6 @@ where /// Pads or truncates the vector in-place to match the specified `width` according to the /// specified alignment `mode` by writing into the provided `buffer`. /// - /// See [`truncate_to_fit`] for details on how truncating is performed. - /// /// If the vector is longer than `width` (in number of items), it will be truncated. /// /// If the vector is shorter than `width`, it will be padded using the `symbol`. @@ -473,7 +460,6 @@ where /// assert_eq!(expected.len(), buf.len()); /// } /// ``` - /// [`truncate_to_fit`]: Self::truncate_to_fit fn pad_to_buffer( &self, width: usize, @@ -510,7 +496,7 @@ where type Slice<'a> = &'a [T] where - T: 'a; + Self: 'a; /// Truncates the slice to match the specified `width` according to the specified alignment `mode`. /// - [`Alignment::Left`]: truncates from the right. @@ -530,8 +516,6 @@ where /// Pads or truncates the slice to match the specified `width` according to the specified alignment `mode`. /// - /// See [`truncate_to_fit`] for details on how truncating is performed. - /// /// If the slice is longer than `width` (in number of items), it will be truncated. /// /// If the slice is shorter than `width`, it will be padded using the `symbol`. @@ -547,7 +531,6 @@ where /// assert_eq!(9, o.capacity()); /// assert_eq!(9, o.len()); /// ``` - /// [`truncate_to_fit`]: Self::truncate_to_fit fn pad(&self, width: usize, mode: Alignment, symbol: Self::Symbol) -> Self::Output { if width < self.len() { return self.truncate_to_fit(width, mode).to_vec(); @@ -570,8 +553,6 @@ where /// Pads or truncates the slice in-place to match the specified `width` according to the /// specified alignment `mode` by writing into the provided `buffer`. /// - /// See [`truncate_to_fit`] for details on how truncating is performed. - /// /// If the slice is longer than `width` (in number of items), it will be truncated. /// /// If the slice is shorter than `width`, it will be padded using the `symbol`. @@ -593,7 +574,6 @@ where /// assert_eq!(7, o.capacity()); /// assert_eq!(7, o.len()); /// ``` - /// [`truncate_to_fit`]: Self::truncate_to_fit fn pad_to_buffer( &self, width: usize, From 94739e087adf4747c2a373ba26d2db28f9dad832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wilhelm=20=C3=85gren?= Date: Fri, 25 Jul 2025 10:38:05 +0200 Subject: [PATCH 2/3] build: bump patch version to 2.0.1 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 6051709..a4939b0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ resolver = "3" [package] name = "padder" -version = "2.0.0" +version = "2.0.1" edition = "2024" description = "A highly efficient Rust crate for padding data during runtime." authors = [ From 732179f5037a1408fa881f9120c079ac897ce1cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wilhelm=20=C3=85gren?= Date: Fri, 25 Jul 2025 10:39:36 +0200 Subject: [PATCH 3/3] build: bump patch version to 2.0.1 --- Cargo.lock | 2 +- src/source.rs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 82b0869..f484bd5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -262,7 +262,7 @@ checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e" [[package]] name = "padder" -version = "2.0.0" +version = "2.0.1" dependencies = [ "criterion", ] diff --git a/src/source.rs b/src/source.rs index c64d24a..acafc27 100644 --- a/src/source.rs +++ b/src/source.rs @@ -48,7 +48,8 @@ impl Source for &str { type Symbol = char; type Buffer = String; type Output = String; - type Slice<'a> = Self + type Slice<'a> + = Self where Self: 'a; @@ -202,7 +203,8 @@ impl Source for String { type Symbol = char; type Buffer = Self; type Output = Self; - type Slice<'a> = &'a str + type Slice<'a> + = &'a str where Self: 'a;