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 upRedo the interface of CFDictionary and CFMutableDictionary #189
Conversation
|
The shared types (FromVoid, ItemRef) from array should probably be moved into base |
|
The ergonomics of using this new interface with kSecImportItemLabel constants style constants as keys isn't great. I'll try to think of what can be done. |
|
This is a nice improvement. |
core-foundation/src/dictionary.rs
Outdated
|
|
||
| /// A trait describing how to convert from the stored *const c_void to the desired T | ||
| pub trait ToVoid { | ||
| fn to_void<'a>(&self) -> *const c_void; |
This comment has been minimized.
This comment has been minimized.
core-foundation/src/dictionary.rs
Outdated
| } | ||
|
|
||
| #[inline] | ||
| pub fn find(&self, key: *const c_void) -> Option<*const c_void> { | ||
| pub fn find<'a>(&self, key: &K) -> Option<ItemRef<'a, V>> where V: FromVoid, K: ToVoid { |
This comment has been minimized.
This comment has been minimized.
jdm
Feb 6, 2018
Member
Seeing no use of 'a in the input arguments is surprising. Should it be related to &self?
core-foundation/src/dictionary.rs
Outdated
|
|
||
| #[inline] | ||
| pub fn find(&self, key: *const c_void) -> Option<*const c_void> { | ||
| pub fn find<'a>(&self, key: &K) -> Option<ItemRef<'a, V>> where V: FromVoid, K: ToVoid { |
This comment has been minimized.
This comment has been minimized.
d4d7885
to
ac44497
|
This is ready for review now. |
|
@bors-servo r+ |
|
|
bors-servo
added a commit
that referenced
this pull request
Feb 7, 2018
Redo the interface of CFDictionary and CFMutableDictionary This is a pretty big change to take advantge of the type parameters. It simplifies things and makes them more safe. <!-- 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/189) <!-- 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.
jrmuizel commentedFeb 3, 2018
•
edited by larsbergstrom
This is a pretty big change to take advantge of the type parameters.
It simplifies things and makes them more safe.
This change is