File tree Expand file tree Collapse file tree 1 file changed +16
-13
lines changed Expand file tree Collapse file tree 1 file changed +16
-13
lines changed Original file line number Diff line number Diff line change @@ -471,19 +471,6 @@ impl<T> Clone for FlumeProgressSender<T> {
471
471
}
472
472
}
473
473
474
- fn same_channel < T > ( a : & async_channel:: Sender < T > , b : & async_channel:: Sender < T > ) -> bool {
475
- assert ! ( std:: mem:: size_of:: <async_channel:: Sender <T >>( ) == std:: mem:: size_of:: <usize >( ) ) ;
476
- fn get_arc_reference < T > ( x : & async_channel:: Sender < T > ) -> & Arc < ( ) > {
477
- unsafe {
478
- // Transmute the reference to MyNewType to a reference to Arc<()>
479
- std:: mem:: transmute :: < _ , & Arc < ( ) > > ( x)
480
- }
481
- }
482
- let a = get_arc_reference ( a) ;
483
- let b = get_arc_reference ( b) ;
484
- Arc :: ptr_eq ( a, b)
485
- }
486
-
487
474
impl < T > FlumeProgressSender < T > {
488
475
/// Create a new progress sender from a flume sender.
489
476
pub fn new ( sender : async_channel:: Sender < T > ) -> Self {
@@ -499,6 +486,22 @@ impl<T> FlumeProgressSender<T> {
499
486
}
500
487
}
501
488
489
+ fn get_as_ptr < T > ( value : & T ) -> Option < usize > {
490
+ use std:: mem;
491
+ if mem:: size_of :: < T > ( ) == std:: mem:: size_of :: < usize > ( ) && mem:: align_of :: < T > ( ) == mem:: align_of :: < usize > ( ) {
492
+ // Safe only if size and alignment requirements are met
493
+ unsafe {
494
+ Some ( mem:: transmute_copy ( value) )
495
+ }
496
+ } else {
497
+ None
498
+ }
499
+ }
500
+
501
+ fn same_channel < T > ( a : & async_channel:: Sender < T > , b : & async_channel:: Sender < T > ) -> bool {
502
+ get_as_ptr ( a) . unwrap ( ) == get_as_ptr ( b) . unwrap ( )
503
+ }
504
+
502
505
impl < T > IdGenerator for FlumeProgressSender < T > {
503
506
fn new_id ( & self ) -> u64 {
504
507
self . id . fetch_add ( 1 , std:: sync:: atomic:: Ordering :: SeqCst )
You can’t perform that action at this time.
0 commit comments