File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change 22
22
//! BSON definition
23
23
24
24
use std:: fmt:: { Display , Error , Formatter } ;
25
- use std:: mem;
26
25
27
26
use chrono:: { DateTime , Timelike , UTC } ;
28
27
use chrono:: offset:: TimeZone ;
@@ -313,10 +312,12 @@ impl Bson {
313
312
}
314
313
}
315
314
Bson :: TimeStamp ( v) => {
316
- let raw: [ i32 ; 2 ] = unsafe { mem:: transmute ( v) } ;
315
+ let time = ( v >> 32 ) as i32 ;
316
+ let inc = ( v & 0xFFFFFFFF ) as i32 ;
317
+
317
318
doc ! {
318
- "t" => ( raw [ 0 ] ) ,
319
- "i" => ( raw [ 1 ] )
319
+ "t" => time ,
320
+ "i" => inc
320
321
}
321
322
}
322
323
Bson :: Binary ( t, ref v) => {
@@ -360,8 +361,7 @@ impl Bson {
360
361
361
362
} else if let Some ( & Bson :: I32 ( t) ) = values. get ( "t" ) {
362
363
if let Some ( & Bson :: I32 ( i) ) = values. get ( "i" ) {
363
- let raw: [ i32 ; 2 ] = [ t, i] ;
364
- let timestamp: i64 = unsafe { mem:: transmute ( raw) } ;
364
+ let timestamp = ( ( t as i64 ) << 32 ) + ( i as i64 ) ;
365
365
return Ok ( Bson :: TimeStamp ( timestamp) )
366
366
}
367
367
You can’t perform that action at this time.
0 commit comments