-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: Better conversions between Utf32String and Utf32Str #50
Comments
As far as I understand the codebase, I don't think pub trait AsRef<Utf32Str<'_>> {
// Required method
fn as_ref(&self) -> &Utf32Str<'_> {
&self.slice(..)
}
} but this does not work since the More generally though, it seems to me that you are treating Here is an example straight from UAX #29: let s = "क्षि";
let utf32_s = Utf32String::from(s);
for g in s.graphemes(true) {
println!("{g} {:?}", g.chars());
}
for ch in utf32_s.slice(..).chars() {
println!("{ch}");
} In my opinion, the fact that Unfortunately, rendering of grapheme clusters is not handled correctly by many terminals anyway, so actually doing things properly in your own code does not guarantee that things will go as expected... In your code examples, I would just use your own types and your own I hope this is helpful! |
It's somewhat helpful, but I'm not satisfied with it. The conversion What I was asking is for Now, if a function expects |
For maximising performance of matching, I have a
Vec<Utf32String>
that I want to match against.It's fairly big (hundreds of thousands of records).
For matching I do something like:
So that I can sort it like so:
And finally, construct a new
Vec<Utf32String>
with the filtered result:Notice that I do
file_name.clone()
twice.Now, to avoid at least 1 clone, I was thinking of refactoring the scoring vector like so:
So far so good, but then I found no way of converting an Utf32Str to Utf32String for the final
Vec<Utf32String>
It would be nice to have, first of all an
AsRef<Utf32Str>
for Utf32String, so that I don't have to call.slice(..)
, next it would be awesome to have aFrom<Utf32Str>
for Utf32String, so that I can do something likeUtf32String::from(file_name)
in the finalVec<Utf32String>
The text was updated successfully, but these errors were encountered: