Skip to content

Commit

Permalink
Merge pull request #94 from Jules-Bertholet/fusediterator
Browse files Browse the repository at this point in the history
Add missing `FusedIterator` impls
  • Loading branch information
Manishearth authored Feb 29, 2024
2 parents 32659a7 + c8ab427 commit 95aab8d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/decompose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use core::fmt::{self, Write};
use core::iter::Fuse;
use core::iter::{Fuse, FusedIterator};
use core::ops::Range;
use tinyvec::TinyVec;

Expand Down Expand Up @@ -151,6 +151,8 @@ impl<I: Iterator<Item = char>> Iterator for Decompositions<I> {
}
}

impl<I: Iterator<Item = char> + FusedIterator> FusedIterator for Decompositions<I> {}

impl<I: Iterator<Item = char> + Clone> fmt::Display for Decompositions<I> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
for c in self.clone() {
Expand Down
7 changes: 6 additions & 1 deletion src/recompose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
// except according to those terms.

use crate::decompose::Decompositions;
use core::fmt::{self, Write};
use core::{
fmt::{self, Write},
iter::FusedIterator,
};
use tinyvec::TinyVec;

#[derive(Clone)]
Expand Down Expand Up @@ -144,6 +147,8 @@ impl<I: Iterator<Item = char>> Iterator for Recompositions<I> {
}
}

impl<I: Iterator<Item = char> + FusedIterator> FusedIterator for Recompositions<I> {}

impl<I: Iterator<Item = char> + Clone> fmt::Display for Recompositions<I> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
for c in self.clone() {
Expand Down
7 changes: 6 additions & 1 deletion src/replace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use core::fmt::{self, Write};
use core::{
fmt::{self, Write},
iter::FusedIterator,
};
use tinyvec::ArrayVec;

/// External iterator for replacements for a string's characters.
Expand Down Expand Up @@ -51,6 +54,8 @@ impl<I: Iterator<Item = char>> Iterator for Replacements<I> {
}
}

impl<I: Iterator<Item = char> + FusedIterator> FusedIterator for Replacements<I> {}

impl<I: Iterator<Item = char> + Clone> fmt::Display for Replacements<I> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
for c in self.clone() {
Expand Down
4 changes: 4 additions & 0 deletions src/stream_safe.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use core::iter::FusedIterator;

use crate::lookups::{
canonical_combining_class, canonical_fully_decomposed, compatibility_fully_decomposed,
stream_safe_trailing_nonstarters,
Expand Down Expand Up @@ -59,6 +61,8 @@ impl<I: Iterator<Item = char>> Iterator for StreamSafe<I> {
}
}

impl<I: Iterator<Item = char> + FusedIterator> FusedIterator for StreamSafe<I> {}

#[derive(Debug)]
pub(crate) struct Decomposition {
pub(crate) leading_nonstarters: usize,
Expand Down

0 comments on commit 95aab8d

Please sign in to comment.