-
Notifications
You must be signed in to change notification settings - Fork 155
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
EqStrUntilNul trait to compare Rust strings (str, String) against CStr16 and CString16 #462
EqStrUntilNul trait to compare Rust strings (str, String) against CStr16 and CString16 #462
Conversation
19fa556
to
688cd54
Compare
688cd54
to
d35338e
Compare
Thanks for the PR! Looks like there is one failing lint:
I have a bit of hesitation on allowing
That said, having the comparison does feel useful to avoid having to do a conversion of one of the operands. I wonder if maybe it would be better to add a new method to |
Ahh, I totally agree that uefi-rs should follow conventions and existing APIs from libstd / libcore.
I like the idea, yeah! I update the PR accordingly soon. |
d35338e
to
e2958c9
Compare
.eq()
on CStr16
and CString16
@nicholasbishop I updated the PR. Let me know what you think. TL;DR: new API: let input: &CStr16 = cstr16!("test");
// test various comparisons with different order (left, right)
assert!(input.eq_str_until_nul(&"test"));
assert!(input.eq_str_until_nul(&String::from("test")));
// now other direction
assert!(String::from("test").eq_str_until_nul(input));
assert!("test".eq_str_until_nul(input)); |
1ab6385
to
6cc6cc8
Compare
6cc6cc8
to
8306f20
Compare
Thank you, the code looks good now. I'd ask @nicholasbishop to also take one final look if there's anything else left to improve before merging.
I'm not against having more helping hands on board of the project 🙂 What do you say, @nicholasbishop? |
8306f20
to
947b565
Compare
Looks good 👍
That sounds good to me as well! |
I cleaned up and improved the code of.eq()
-implementations forCStr16
andCString16
. Now it is easy to compare&str
andString
from the standard library with UEFI strings.Let me know what you think.According to the discussion, I changed the PR. Now there is a common trait which allows to compare Rust strings (str, String) against CStr16 and CString16.
PS: If it's okay for you, I'd be happy to support you as a maintainer/developer in
uefi-rs
as I'm submitting stuff to uefi-rs anyway from time to time. Just let me know if you need support