Skip to content

Commit 6f96a23

Browse files
committed
restore iterators
1 parent 9b1b7f9 commit 6f96a23

File tree

2 files changed

+193
-105
lines changed

2 files changed

+193
-105
lines changed

src/lib.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ pub use sentence::{USentenceBoundIndices, USentenceBounds, UnicodeSentences};
6565
pub use tables::UNICODE_VERSION;
6666
pub use word::{UWordBoundIndices, UWordBounds};
6767

68+
use crate::word::{UnicodeWordIndices, UnicodeWords};
69+
6870
mod grapheme;
6971
mod sentence;
7072
#[rustfmt::skip]
@@ -136,7 +138,7 @@ pub trait UnicodeSegmentation {
136138
///
137139
/// assert_eq!(&uw1[..], b);
138140
/// ```
139-
fn unicode_words(&self) -> impl Iterator<Item = &'_ str>;
141+
fn unicode_words(&self) -> UnicodeWords;
140142

141143
/// Returns an iterator over the words of `self`, separated on
142144
/// [UAX#29 word boundaries](http://www.unicode.org/reports/tr29/#Word_Boundaries), and their
@@ -160,7 +162,7 @@ pub trait UnicodeSegmentation {
160162
///
161163
/// assert_eq!(&uwi1[..], b);
162164
/// ```
163-
fn unicode_word_indices(&self) -> impl Iterator<Item = (usize, &'_ str)>;
165+
fn unicode_word_indices(&self) -> UnicodeWordIndices;
164166

165167
/// Returns an iterator over substrings of `self` separated on
166168
/// [UAX#29 word boundaries](http://www.unicode.org/reports/tr29/#Word_Boundaries).
@@ -176,7 +178,7 @@ pub trait UnicodeSegmentation {
176178
///
177179
/// assert_eq!(&swu1[..], b);
178180
/// ```
179-
fn split_word_bounds(&self) -> impl DoubleEndedIterator<Item = &'_ str>;
181+
fn split_word_bounds(&self) -> UWordBounds;
180182

181183
/// Returns an iterator over substrings of `self`, split on UAX#29 word boundaries,
182184
/// and their offsets. See `split_word_bounds()` for more information.
@@ -191,7 +193,7 @@ pub trait UnicodeSegmentation {
191193
///
192194
/// assert_eq!(&swi1[..], b);
193195
/// ```
194-
fn split_word_bound_indices(&self) -> impl DoubleEndedIterator<Item = (usize, &'_ str)>;
196+
fn split_word_bound_indices(&self) -> UWordBoundIndices;
195197

196198
/// Returns an iterator over substrings of `self` separated on
197199
/// [UAX#29 sentence boundaries](http://www.unicode.org/reports/tr29/#Sentence_Boundaries).
@@ -261,22 +263,22 @@ impl UnicodeSegmentation for str {
261263
}
262264

263265
#[inline]
264-
fn unicode_words(&self) -> impl Iterator<Item = &'_ str> {
266+
fn unicode_words(&self) -> UnicodeWords {
265267
word::new_unicode_words(self)
266268
}
267269

268270
#[inline]
269-
fn unicode_word_indices(&self) -> impl Iterator<Item = (usize, &'_ str)> {
271+
fn unicode_word_indices(&self) -> UnicodeWordIndices {
270272
word::new_unicode_word_indices(self)
271273
}
272274

273275
#[inline]
274-
fn split_word_bounds(&self) -> impl DoubleEndedIterator<Item = &'_ str> {
276+
fn split_word_bounds(&self) -> UWordBounds {
275277
word::new_word_bounds(self)
276278
}
277279

278280
#[inline]
279-
fn split_word_bound_indices(&self) -> impl DoubleEndedIterator<Item = (usize, &'_ str)> {
281+
fn split_word_bound_indices(&self) -> UWordBoundIndices {
280282
word::new_word_bound_indices(self)
281283
}
282284

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy