@@ -2,6 +2,7 @@ use std::borrow::Borrow;
22use std:: cmp:: { Ordering , PartialEq , PartialOrd } ;
33use std:: fmt:: { self , Debug , Display } ;
44use std:: ops:: Deref ;
5+ use std:: ptr:: { addr_of, addr_of_mut} ;
56
67use hdf5_sys:: h5t:: {
78 H5T_cdata_t , H5T_class_t , H5T_cset_t , H5T_order_t , H5T_sign_t , H5T_str_t , H5Tarray_create2 ,
@@ -171,8 +172,8 @@ impl Datatype {
171172 let dst = dst. borrow ( ) ;
172173 let mut cdata = H5T_cdata_t :: default ( ) ;
173174 h5lock ! ( {
174- let noop = H5Tfind ( * H5T_NATIVE_INT , * H5T_NATIVE_INT , & mut ( & mut cdata as * mut _ ) ) ;
175- if H5Tfind ( self . id( ) , dst. id( ) , & mut ( & mut cdata as * mut _ ) ) == noop {
175+ let noop = H5Tfind ( * H5T_NATIVE_INT , * H5T_NATIVE_INT , & mut addr_of_mut! ( cdata) ) ;
176+ if H5Tfind ( self . id( ) , dst. id( ) , & mut addr_of_mut! ( cdata) ) == noop {
176177 Some ( Conversion :: NoOp )
177178 } else {
178179 match H5Tcompiler_conv ( self . id( ) , dst. id( ) ) {
@@ -235,7 +236,7 @@ impl Datatype {
235236 let mut members: Vec <EnumMember > = Vec :: new( ) ;
236237 for idx in 0 ..h5try!( H5Tget_nmembers ( id) ) as _ {
237238 let mut value: u64 = 0 ;
238- h5try!( H5Tget_member_value ( id, idx, ( & mut value as * mut u64 ) . cast( ) ) ) ;
239+ h5try!( H5Tget_member_value ( id, idx, addr_of_mut! ( value) . cast( ) ) ) ;
239240 let name = H5Tget_member_name ( id, idx) ;
240241 members. push( EnumMember { name: string_from_cstr( name) , value } ) ;
241242 h5_free_memory( name. cast( ) ) ;
@@ -277,7 +278,7 @@ impl Datatype {
277278 let ndims = h5try!( H5Tget_array_ndims ( id) ) ;
278279 if ndims == 1 {
279280 let mut len: hsize_t = 0 ;
280- h5try!( H5Tget_array_dims2 ( id, & mut len as * mut _ ) ) ;
281+ h5try!( H5Tget_array_dims2 ( id, addr_of_mut! ( len) ) ) ;
281282 Ok ( TD :: FixedArray ( Box :: new( base_dt. to_descriptor( ) ?) , len as _) )
282283 } else {
283284 Err ( "Multi-dimensional array datatypes are not supported" . into( ) )
@@ -344,15 +345,17 @@ impl Datatype {
344345 } ) ,
345346 TD :: Boolean => {
346347 let bool_id = h5try!( H5Tenum_create ( * H5T_NATIVE_INT8 ) ) ;
348+ let zero = 0_i8 ;
347349 h5try!( H5Tenum_insert (
348350 bool_id,
349351 b"FALSE\0 " . as_ptr( ) . cast( ) ,
350- ( & 0_i8 as * const i8 ) . cast( )
352+ addr_of! ( zero ) . cast( ) ,
351353 ) ) ;
354+ let one = 1_i8 ;
352355 h5try!( H5Tenum_insert (
353356 bool_id,
354357 b"TRUE\0 " . as_ptr( ) . cast( ) ,
355- ( & 1_i8 as * const i8 ) . cast( )
358+ addr_of! ( one ) . cast( ) ,
356359 ) ) ;
357360 Ok ( bool_id)
358361 }
@@ -364,7 +367,7 @@ impl Datatype {
364367 h5try!( H5Tenum_insert (
365368 enum_id,
366369 name. as_ptr( ) ,
367- ( & member. value as * const u64 ) . cast( )
370+ addr_of! ( member. value) . cast( )
368371 ) ) ;
369372 }
370373 Ok ( enum_id)
@@ -383,7 +386,7 @@ impl Datatype {
383386 TD :: FixedArray ( ref ty, len) => {
384387 let elem_dt = Self :: from_descriptor( ty) ?;
385388 let dims = len as hsize_t;
386- Ok ( h5try!( H5Tarray_create2 ( elem_dt. id( ) , 1 , & dims as * const _ ) ) )
389+ Ok ( h5try!( H5Tarray_create2 ( elem_dt. id( ) , 1 , addr_of! ( dims) ) ) )
387390 }
388391 TD :: FixedAscii ( size) => string_type( Some ( size) , H5T_cset_t :: H5T_CSET_ASCII ) ,
389392 TD :: FixedUnicode ( size) => string_type( Some ( size) , H5T_cset_t :: H5T_CSET_UTF8 ) ,
0 commit comments