diff options
Diffstat (limited to 'src/passwordmaker/grapheme.rs')
-rw-r--r-- | src/passwordmaker/grapheme.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/passwordmaker/grapheme.rs b/src/passwordmaker/grapheme.rs new file mode 100644 index 0000000..ee10146 --- /dev/null +++ b/src/passwordmaker/grapheme.rs @@ -0,0 +1,11 @@ +use unicode_segmentation::UnicodeSegmentation; +#[derive(Clone)] +pub(super) struct Grapheme<'a>(&'a str); + +impl<'a> Grapheme<'a> { + pub(super) fn iter_from_str(string : &'a str) -> impl Iterator<Item=Grapheme<'a>> { + string.graphemes(true).map(Self::extract_grapheme_unchecked) + } + pub(super) fn get<'b>(&'b self) -> &'a str { self.0 } + fn extract_grapheme_unchecked(s : &str) -> Grapheme { Grapheme(s) } +}
\ No newline at end of file |