Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement From<&str> for CFString #128
Merged
+7
−0
Conversation
|
@bors-servo r+ |
|
|
bors-servo
added a commit
that referenced
this pull request
Nov 22, 2017
Implement From<&str> for CFString
I'm not sure if you have any strict policies on what types you usually accept as parameters to the safe wrappers. So I'm not sure if you want this or not. But my reasons are:
I create `system-configuration` and `system-configuration-sys` crates as bindings to that API. In the [`SCDynamicStore`] module a lot of the functions take a `CFStringRef` as argument. It would be more ergonomic if this safe wrapper type could deal with Rust strings directly, so I can do:
```rust
let store = SCDynamicStore::create("my-dynamic-store");
let dict = store.find("State:/Network/Global/IPv4");
```
But at the same time I don't want to make it harder to use for people who already sit on `CFString` objects. So with this new `From<&str>` impl my API can be used both with `&str` and `CFString` if I implement the methods as `<S: Into<CFString>>`.
[`SCDynamicStore`]: https://developer.apple.com/documentation/systemconfiguration/scdynamicstore?language=objc
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-foundation-rs/128)
<!-- Reviewable:end -->
|
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
faern commentedNov 22, 2017
•
edited by larsbergstrom
I'm not sure if you have any strict policies on what types you usually accept as parameters to the safe wrappers. So I'm not sure if you want this or not. But my reasons are:
I create
system-configurationandsystem-configuration-syscrates as bindings to that API. In theSCDynamicStoremodule a lot of the functions take aCFStringRefas argument. It would be more ergonomic if this safe wrapper type could deal with Rust strings directly, so I can do:But at the same time I don't want to make it harder to use for people who already sit on
CFStringobjects. So with this newFrom<&str>impl my API can be used both with&strandCFStringif I implement the methods as<S: Into<CFString>>.This change is