Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ repository = "https://github.com/tormol/encode_unicode"
documentation = "https://docs.rs/encode_unicode/"
authors = ["Torbjørn Birch Moltu <t.b.moltu@lyse.net>"]
edition = "2021"
include = ["Cargo.toml", "README.md", "LICENSE-MIT", "LICENSE-APACHE", "src/**/*.rs", "RELEASES.md", "AUTHORS.md"]

[dependencies.ascii]
optional = true
Expand Down
2 changes: 1 addition & 1 deletion src/decoding_iterators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}
Expand Down
24 changes: 12 additions & 12 deletions src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,26 +605,26 @@ fn combine_surrogates(first: u16, second: u16) -> char {
/// Adds `.utf8chars()` and `.utf16chars()` iterator constructors to `&str`.
pub trait StrExt: AsRef<str> {
/// 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)
}
}
Expand Down Expand Up @@ -938,7 +938,7 @@ pub trait SliceExt: Index<RangeFull> {
/// (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,
Expand Down Expand Up @@ -999,14 +999,14 @@ pub trait SliceExt: Index<RangeFull> {
/// 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<S: ?Sized+Index<RangeFull>> 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())
}
}
4 changes: 2 additions & 2 deletions src/utf16_iterators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
}
Expand Down Expand Up @@ -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))
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/utf8_iterators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
}
Expand Down Expand Up @@ -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))
}
}
Expand Down