-
Notifications
You must be signed in to change notification settings - Fork 235
Add a type parameter to CFArray #127
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
Conversation
core-foundation/src/array.rs
Outdated
impl Drop for CFArray { | ||
/// A trait describing how to convert from the stored *const c_void to the desired T | ||
pub trait FromVoid<T> { | ||
fn from_void(x: *const c_void) -> T; |
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.
The type parameter seems redundant when we could just use Self instead.
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.
Fixed
This puts us on a path to greater type safety when using CFArrays
85310fb
to
0253ee2
Compare
@bors-servo: r+ |
📌 Commit 0253ee2 has been approved by |
Add a type parameter to CFArray This puts us on a path to greater type safety when using CFArrays <!-- 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/127) <!-- Reviewable:end -->
☀️ Test successful - status-travis |
impl Drop for CFArray { | ||
/// A trait describing how to convert from the stored *const c_void to the desired T | ||
pub trait FromVoid { | ||
fn from_void(x: *const c_void) -> Self; |
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.
This should be unsafe.
|
||
impl FromVoid for CFType { | ||
fn from_void(x: *const c_void) -> CFType { | ||
unsafe { TCFType::wrap_under_get_rule(mem::transmute(x)) } |
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.
This is unsound, one can pass 0xdeadbeef as *const c_void
or any other arbitrary and trigger UB.
Does #134 address this sufficiently? |
Add functions to get font tag information This depends on servo/core-foundation-rs#127 for CFArray<u32>. I'm just putting it up for reference right now. <!-- 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-graphics-rs/104) <!-- Reviewable:end -->
This puts us on a path to greater type safety when using CFArrays
This change is