-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Use IndexSet instead of Vec for codepoints #283
Conversation
This ensures that codepoints are unique, but also respects the original order in which they appear in the file.
All it may end up doing is meaning users of the library have to pull in This creates a case for keeping |
The readme says:
Hm :) Are we gonna let that stop our OCD? |
Otherwise, I'm ok with pulling it in and exposing it directly in the API. I don't like making delegation functions... |
Personally I'd rather not, however it is a common dependency so definitely not the end of the world. As far as I can tell from their documentation, only |
So I'm okay going either way with this. Fwiw it would be easy enough to modify the contents without needing to have the crate in scope, e.g. my_glyph.codepoints.clear();
my_glyph.codepoints.extend(['a', 'b', 'c']); but I think maybe not having it be public API is a strictly better design, so I'll go ahead and do that. |
Okay, I've updated this with a new custom Codepoints type, wrapping an indexset. |
src/glyph/codepoints.rs
Outdated
self.0.is_empty() | ||
} | ||
|
||
/// Set the codepoints. See [Codepoints::new][] for useage. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd remove the []
here, at best they go through to the rustdoc as is, or at worst they break your link.
While I'm on this line of code, it's "usage" 😉
Looks good to me! The only this to bear in mind is that we are still exposing the iterator type from You could also trivially make a borrowing iterator that returns owned fn iter(&self) -> impl Iterator<Item = char> {
self.0.iter().copied()
} |
@RickyDaMa unfortunately I can't use |
Yeah in Maybe in some future version of the Rust compiler 😄 |
70a2b3c
to
a91f187
Compare
This ensures that codepoints are unique, but also respects the original order in which they appear in the file.
This is an alternative to #268. Although it brings in a dependency, it leads to a much simpler and more efficient implementation overall.
Thoughts @madig ?