@@ -23,25 +23,25 @@ use base::{CFIndexConvertible, TCFType, CFRange};
23
23
pub struct CFArray < T = * const c_void > ( CFArrayRef , PhantomData < T > ) ;
24
24
25
25
/// A trait describing how to convert from the stored *const c_void to the desired T
26
- pub trait FromVoid {
27
- fn from_void ( x : * const c_void ) -> Self ;
26
+ pub unsafe trait FromVoid {
27
+ unsafe fn from_void ( x : * const c_void ) -> Self ;
28
28
}
29
29
30
- impl FromVoid for u32 {
31
- fn from_void ( x : * const c_void ) -> u32 {
30
+ unsafe impl FromVoid for u32 {
31
+ unsafe fn from_void ( x : * const c_void ) -> u32 {
32
32
x as usize as u32
33
33
}
34
34
}
35
35
36
- impl FromVoid for * const c_void {
37
- fn from_void ( x : * const c_void ) -> * const c_void {
36
+ unsafe impl FromVoid for * const c_void {
37
+ unsafe fn from_void ( x : * const c_void ) -> * const c_void {
38
38
x
39
39
}
40
40
}
41
41
42
- impl FromVoid for CFType {
43
- fn from_void ( x : * const c_void ) -> CFType {
44
- unsafe { TCFType :: wrap_under_get_rule ( mem:: transmute ( x) ) }
42
+ unsafe impl FromVoid for CFType {
43
+ unsafe fn from_void ( x : * const c_void ) -> CFType {
44
+ TCFType :: wrap_under_get_rule ( mem:: transmute ( x) )
45
45
}
46
46
}
47
47
@@ -121,7 +121,7 @@ impl<T> CFArray<T> {
121
121
#[ inline]
122
122
pub fn get ( & self , index : CFIndex ) -> T where T : FromVoid {
123
123
assert ! ( index < self . len( ) ) ;
124
- T :: from_void ( unsafe { CFArrayGetValueAtIndex ( self . 0 , index) } )
124
+ unsafe { T :: from_void ( CFArrayGetValueAtIndex ( self . 0 , index) ) }
125
125
}
126
126
127
127
pub fn get_values ( & self , range : CFRange ) -> Vec < * const c_void > {
0 commit comments