@@ -2,6 +2,7 @@ use std::borrow::Borrow;
2
2
use std:: cmp:: { Ordering , PartialEq , PartialOrd } ;
3
3
use std:: fmt:: { self , Debug , Display } ;
4
4
use std:: ops:: Deref ;
5
+ use std:: ptr:: { addr_of, addr_of_mut} ;
5
6
6
7
use hdf5_sys:: h5t:: {
7
8
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 {
171
172
let dst = dst. borrow ( ) ;
172
173
let mut cdata = H5T_cdata_t :: default ( ) ;
173
174
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 {
176
177
Some ( Conversion :: NoOp )
177
178
} else {
178
179
match H5Tcompiler_conv ( self . id( ) , dst. id( ) ) {
@@ -235,7 +236,7 @@ impl Datatype {
235
236
let mut members: Vec <EnumMember > = Vec :: new( ) ;
236
237
for idx in 0 ..h5try!( H5Tget_nmembers ( id) ) as _ {
237
238
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( ) ) ) ;
239
240
let name = H5Tget_member_name ( id, idx) ;
240
241
members. push( EnumMember { name: string_from_cstr( name) , value } ) ;
241
242
h5_free_memory( name. cast( ) ) ;
@@ -277,7 +278,7 @@ impl Datatype {
277
278
let ndims = h5try!( H5Tget_array_ndims ( id) ) ;
278
279
if ndims == 1 {
279
280
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) ) ) ;
281
282
Ok ( TD :: FixedArray ( Box :: new( base_dt. to_descriptor( ) ?) , len as _) )
282
283
} else {
283
284
Err ( "Multi-dimensional array datatypes are not supported" . into( ) )
@@ -344,15 +345,17 @@ impl Datatype {
344
345
} ) ,
345
346
TD :: Boolean => {
346
347
let bool_id = h5try!( H5Tenum_create ( * H5T_NATIVE_INT8 ) ) ;
348
+ let zero = 0_i8 ;
347
349
h5try!( H5Tenum_insert (
348
350
bool_id,
349
351
b"FALSE\0 " . as_ptr( ) . cast( ) ,
350
- ( & 0_i8 as * const i8 ) . cast( )
352
+ addr_of! ( zero ) . cast( ) ,
351
353
) ) ;
354
+ let one = 1_i8 ;
352
355
h5try!( H5Tenum_insert (
353
356
bool_id,
354
357
b"TRUE\0 " . as_ptr( ) . cast( ) ,
355
- ( & 1_i8 as * const i8 ) . cast( )
358
+ addr_of! ( one ) . cast( ) ,
356
359
) ) ;
357
360
Ok ( bool_id)
358
361
}
@@ -364,7 +367,7 @@ impl Datatype {
364
367
h5try!( H5Tenum_insert (
365
368
enum_id,
366
369
name. as_ptr( ) ,
367
- ( & member. value as * const u64 ) . cast( )
370
+ addr_of! ( member. value) . cast( )
368
371
) ) ;
369
372
}
370
373
Ok ( enum_id)
@@ -383,7 +386,7 @@ impl Datatype {
383
386
TD :: FixedArray ( ref ty, len) => {
384
387
let elem_dt = Self :: from_descriptor( ty) ?;
385
388
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) ) ) )
387
390
}
388
391
TD :: FixedAscii ( size) => string_type( Some ( size) , H5T_cset_t :: H5T_CSET_ASCII ) ,
389
392
TD :: FixedUnicode ( size) => string_type( Some ( size) , H5T_cset_t :: H5T_CSET_UTF8 ) ,
0 commit comments