-
Notifications
You must be signed in to change notification settings - Fork 519
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
Allow the name and value in set_string
to be 2 different types
#3412
base: master
Are you sure you want to change the base?
Conversation
…h fulfilling AsRef<str>
Thanks for the contribution. Is this an attempt to fix #3313? |
OK, how about the other methods mentioned in that issue like |
@microsoft-github-policy-service agree |
|
||
#[test] | ||
fn string() -> Result<()> { | ||
let test_key = "software\\windows-rs\\tests\\string"; | ||
_ = CURRENT_USER.remove_tree(test_key); | ||
let key = CURRENT_USER.create(test_key)?; | ||
|
||
key.set_string("string", "value")?; | ||
key.set_string("string", Cow::Owned("lolz".to_string()))?; |
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.
Please append the new tests rather than rewriting existing tests - that way we know the existing tested code continues to work without much reasoning.
Also, please actually test the changes before pushing a PR. 😉
"lolz" != "value"
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.
Sorry, copy pasted from rust playground and didn't realize I changed the value name.
BTW, I didn't update |
Passing an empty array seems like a perfectly reasonable thing to do so I'd rather not break that. 😊 |
Currently,
windows_registry::key::Key::set_string
takes one generic typeT
which implementsAsRef<str>
, which is the type of the argumentsname
andvalue
. This signature is too restrictive, since both arguments must be of the same concrete type, while it should accept, for example,key.set_string(String::from("Name"),"Value")
.This PR adds a new generic type
U
, with the same trait bound asT
and which is the type ofvalue
, thereby allowing the aforementioned situation and similar cases where the 2 arguments have different concrete types that fulfill the same trait bound.Fixes: #3313