From 3b6fedf93d5bb2e40450fd0d327f5953c4e9c4d3 Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Tue, 16 Dec 2025 15:28:31 +0100 Subject: [PATCH 1/2] Exclude development scripts from published package During a dependency review we noticed that the encode_unicode crate includes various development scripts. These development scripts shouldn't be there as they might, at some point become problematic. As of now they prevent any downstream user from enabling the `[bans.build.interpreted]` option of cargo deny. I opted for using an explicit include list instead of an exclude list to prevent these files from being included in the published packages to make sure that everything that's included is an conscious choice. --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 3bc0d33..420047f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ repository = "https://github.com/tormol/encode_unicode" documentation = "https://docs.rs/encode_unicode/" authors = ["Torbjørn Birch Moltu "] edition = "2021" +include = ["Cargo.toml", "README.md", "LICENSE-MIT", "LICENSE-APACHE", "src/**/*.rs", "RELEASES.md", "AUTHORS.md"] [dependencies.ascii] optional = true From 3c5e710f934b1645e475b672a0c5cc23e706cf7a Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Tue, 16 Dec 2025 15:29:09 +0100 Subject: [PATCH 2/2] Fix warnings --- src/decoding_iterators.rs | 2 +- src/traits.rs | 24 ++++++++++++------------ src/utf16_iterators.rs | 4 ++-- src/utf8_iterators.rs | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/decoding_iterators.rs b/src/decoding_iterators.rs index 92bc060..ea51772 100644 --- a/src/decoding_iterators.rs +++ b/src/decoding_iterators.rs @@ -223,7 +223,7 @@ pub struct Utf8CharDecoder<'a> { index: usize, } impl<'a> From<&'a[u8]> for Utf8CharDecoder<'a> { - fn from(s: &[u8]) -> Utf8CharDecoder { + fn from(s: &[u8]) -> Utf8CharDecoder<'_> { Utf8CharDecoder { slice: s, index: 0 } } } diff --git a/src/traits.rs b/src/traits.rs index 53b1211..55c8535 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -605,26 +605,26 @@ fn combine_surrogates(first: u16, second: u16) -> char { /// Adds `.utf8chars()` and `.utf16chars()` iterator constructors to `&str`. pub trait StrExt: AsRef { /// Equivalent to `.chars()` but produces `Utf8Char`s. - fn utf8chars(&self) -> Utf8Chars; + fn utf8chars(&self) -> Utf8Chars<'_>; /// Equivalent to `.chars()` but produces `Utf16Char`s. - fn utf16chars(&self) -> Utf16Chars; + fn utf16chars(&self) -> Utf16Chars<'_>; /// Equivalent to `.char_indices()` but produces `Utf8Char`s. - fn utf8char_indices(&self) -> Utf8CharIndices; + fn utf8char_indices(&self) -> Utf8CharIndices<'_>; /// Equivalent to `.char_indices()` but produces `Utf16Char`s. - fn utf16char_indices(&self) -> Utf16CharIndices; + fn utf16char_indices(&self) -> Utf16CharIndices<'_>; } impl StrExt for str { - fn utf8chars(&self) -> Utf8Chars { + fn utf8chars(&self) -> Utf8Chars<'_> { Utf8Chars::from(self) } - fn utf16chars(&self) -> Utf16Chars { + fn utf16chars(&self) -> Utf16Chars<'_> { Utf16Chars::from(self) } - fn utf8char_indices(&self) -> Utf8CharIndices { + fn utf8char_indices(&self) -> Utf8CharIndices<'_> { Utf8CharIndices::from(self) } - fn utf16char_indices(&self) -> Utf16CharIndices { + fn utf16char_indices(&self) -> Utf16CharIndices<'_> { Utf16CharIndices::from(self) } } @@ -938,7 +938,7 @@ pub trait SliceExt: Index { /// (11, Utf8ErrorKind::TooFewBytes), // (but it was not the last element returned!) /// ]); /// ``` - fn utf8char_indices(&self) -> Utf8CharDecoder where Self::Output: Borrow<[u8]>; + fn utf8char_indices(&self) -> Utf8CharDecoder<'_> where Self::Output: Borrow<[u8]>; /// Decode `u16` slices as UTF-16 and iterate over the codepoints as `Utf16Char`s, @@ -999,14 +999,14 @@ pub trait SliceExt: Index { /// assert_eq!(iter.next(), None); /// assert_eq!(iter.as_slice(), []) /// ``` - fn utf16char_indices(&self) -> Utf16CharDecoder where Self::Output: Borrow<[u16]>; + fn utf16char_indices(&self) -> Utf16CharDecoder<'_> where Self::Output: Borrow<[u16]>; } impl> SliceExt for S { - fn utf8char_indices(&self) -> Utf8CharDecoder where Self::Output: Borrow<[u8]> { + fn utf8char_indices(&self) -> Utf8CharDecoder<'_> where Self::Output: Borrow<[u8]> { Utf8CharDecoder::from(self[..].borrow()) } - fn utf16char_indices(&self) -> Utf16CharDecoder where Self::Output: Borrow<[u16]> { + fn utf16char_indices(&self) -> Utf16CharDecoder<'_> where Self::Output: Borrow<[u16]> { Utf16CharDecoder::from(self[..].borrow()) } } diff --git a/src/utf16_iterators.rs b/src/utf16_iterators.rs index 30dcd80..42f9006 100644 --- a/src/utf16_iterators.rs +++ b/src/utf16_iterators.rs @@ -155,7 +155,7 @@ pub struct Utf16CharIndices<'a>{ index: usize, } impl<'a> From<&'a str> for Utf16CharIndices<'a> { - fn from(s: &str) -> Utf16CharIndices { + fn from(s: &str) -> Utf16CharIndices<'_> { Utf16CharIndices{str: s, index: 0} } } @@ -222,7 +222,7 @@ impl<'a> fmt::Debug for Utf16CharIndices<'a> { #[derive(Clone)] pub struct Utf16Chars<'a>(Utf16CharIndices<'a>); impl<'a> From<&'a str> for Utf16Chars<'a> { - fn from(s: &str) -> Utf16Chars { + fn from(s: &str) -> Utf16Chars<'_> { Utf16Chars(Utf16CharIndices::from(s)) } } diff --git a/src/utf8_iterators.rs b/src/utf8_iterators.rs index b37c687..b2d4506 100644 --- a/src/utf8_iterators.rs +++ b/src/utf8_iterators.rs @@ -234,7 +234,7 @@ pub struct Utf8CharIndices<'a>{ index: usize, } impl<'a> From<&'a str> for Utf8CharIndices<'a> { - fn from(s: &str) -> Utf8CharIndices { + fn from(s: &str) -> Utf8CharIndices<'_> { Utf8CharIndices{str: s, index: 0} } } @@ -303,7 +303,7 @@ impl<'a> fmt::Debug for Utf8CharIndices<'a> { #[derive(Clone)] pub struct Utf8Chars<'a>(Utf8CharIndices<'a>); impl<'a> From<&'a str> for Utf8Chars<'a> { - fn from(s: &str) -> Utf8Chars { + fn from(s: &str) -> Utf8Chars<'_> { Utf8Chars(Utf8CharIndices::from(s)) } }