Skip to content

Commit

Permalink
Use dyn for dynamic dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
lqf96 committed Nov 12, 2019
1 parent e438fc5 commit d3a097f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions core-graphics/src/data_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ impl CGDataProvider {
///
/// This is double-boxed because the Core Text API requires that the userdata be a single
/// pointer.
pub unsafe fn from_custom_data(custom_data: Box<Box<CustomData>>) -> Self {
pub unsafe fn from_custom_data(custom_data: Box<Box<dyn CustomData>>) -> Self {
let (ptr, len) = (custom_data.ptr() as *const c_void, custom_data.len());
let userdata = mem::transmute::<Box<Box<CustomData>>, &mut c_void>(custom_data);
let userdata = mem::transmute::<Box<Box<dyn CustomData>>, &mut c_void>(custom_data);
let data_provider = CGDataProviderCreateWithData(userdata, ptr, len, Some(release));
return CGDataProvider::from_ptr(data_provider);

unsafe extern "C" fn release(info: *mut c_void, _: *const c_void, _: size_t) {
drop(mem::transmute::<*mut c_void, Box<Box<CustomData>>>(info))
drop(mem::transmute::<*mut c_void, Box<Box<dyn CustomData>>>(info))
}
}
}
Expand Down

0 comments on commit d3a097f

Please sign in to comment.