@@ -19,6 +19,25 @@ pub struct GraphemeIndices<'a> {
1919iter : Graphemes < ' a > ,
2020}
2121
22+ impl < ' a > GraphemeIndices < ' a > {
23+ #[ inline]
24+ /// View the underlying data (the part yet to be iterated) as a slice of the original string.
25+ ///
26+ /// ```rust
27+ /// # use unicode_segmentation::UnicodeSegmentation;
28+ /// let mut iter = "abc".grapheme_indices(true);
29+ /// assert_eq!(iter.as_str(), "abc");
30+ /// iter.next();
31+ /// assert_eq!(iter.as_str(), "bc");
32+ /// iter.next();
33+ /// iter.next();
34+ /// assert_eq!(iter.as_str(), "");
35+ /// ```
36+ pub fn as_str ( & self ) ->& ' a str {
37+ self . iter . as_str ( )
38+ }
39+ }
40+
2241impl < ' a > Iterator for GraphemeIndices < ' a > {
2342type Item =( usize , & ' a str ) ;
2443
@@ -51,6 +70,25 @@ pub struct Graphemes<'a> {
5170regional_count_back : Option < usize > ,
5271}
5372
73+ impl < ' a > Graphemes < ' a > {
74+ #[ inline]
75+ /// View the underlying data (the part yet to be iterated) as a slice of the original string.
76+ ///
77+ /// ```rust
78+ /// # use unicode_segmentation::UnicodeSegmentation;
79+ /// let mut iter = "abc".graphemes(true);
80+ /// assert_eq!(iter.as_str(), "abc");
81+ /// iter.next();
82+ /// assert_eq!(iter.as_str(), "bc");
83+ /// iter.next();
84+ /// iter.next();
85+ /// assert_eq!(iter.as_str(), "");
86+ /// ```
87+ pub fn as_str ( & self ) ->& ' a str {
88+ self . string
89+ }
90+ }
91+
5492// state machine for cluster boundary rules
5593#[ derive( Copy , Clone , PartialEq , Eq ) ]
5694enum GraphemeState {