From 5e51b706d54a26470f33d1342f4666d5aab921fc Mon Sep 17 00:00:00 2001 From: Andreas Grois Date: Sun, 9 Oct 2022 00:06:35 +0200 Subject: Initial Commit: PasswordMaker itself. It's compiling, and the public interface is semi-OK now. The internals are still a bit gory, but they'll likely see an iteartion later on anyhow. --- src/passwordmaker/grapheme.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/passwordmaker/grapheme.rs (limited to 'src/passwordmaker/grapheme.rs') 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> { + 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 -- cgit v1.2.3