File tree 6 files changed +13
-35
lines changed
6 files changed +13
-35
lines changed Original file line number Diff line number Diff line change @@ -89,12 +89,8 @@ struct MySender<F, T> {
89
89
keep_running_flag : Arc < AtomicBool > ,
90
90
}
91
91
92
- fn _assert ( ) {
93
- fn _assert_send < T : Send > ( ) { }
94
- fn _assert_sync < T : Sync > ( ) { }
95
- _assert_send :: < CpuPool > ( ) ;
96
- _assert_sync :: < CpuPool > ( ) ;
97
- }
92
+ trait AssertSendSync : Send + Sync { }
93
+ impl AssertSendSync for CpuPool { }
98
94
99
95
struct Inner {
100
96
tx : Mutex < mpsc:: Sender < Message > > ,
Original file line number Diff line number Diff line change @@ -106,14 +106,8 @@ pub struct Sender<T> {
106
106
#[ derive( Debug ) ]
107
107
pub struct UnboundedSender < T > ( Sender < T > ) ;
108
108
109
- fn _assert_kinds ( ) {
110
- fn _assert_send < T : Send > ( ) { }
111
- fn _assert_sync < T : Sync > ( ) { }
112
- fn _assert_clone < T : Clone > ( ) { }
113
- _assert_send :: < UnboundedSender < u32 > > ( ) ;
114
- _assert_sync :: < UnboundedSender < u32 > > ( ) ;
115
- _assert_clone :: < UnboundedSender < u32 > > ( ) ;
116
- }
109
+ trait AssertKinds : Send + Sync + Clone { }
110
+ impl AssertKinds for UnboundedSender < u32 > { }
117
111
118
112
119
113
/// The receiving end of a channel which implements the `Stream` trait.
Original file line number Diff line number Diff line change @@ -43,8 +43,8 @@ impl AtomicTask {
43
43
/// Create an `AtomicTask` initialized with the given `Task`
44
44
pub fn new ( ) -> AtomicTask {
45
45
// Make sure that task is Sync
46
- fn is_sync < T : Sync > ( ) { }
47
- is_sync :: < Task > ( ) ;
46
+ trait AssertSync : Sync { }
47
+ impl AssertSync for Task { }
48
48
49
49
AtomicTask {
50
50
state : AtomicUsize :: new ( WAITING ) ,
Original file line number Diff line number Diff line change @@ -61,10 +61,8 @@ pub struct Task {
61
61
events : UnparkEvents ,
62
62
}
63
63
64
- fn _assert_kinds ( ) {
65
- fn _assert_send < T : Send > ( ) { }
66
- _assert_send :: < Task > ( ) ;
67
- }
64
+ trait AssertSend : Send { }
65
+ impl AssertSend for Task { }
68
66
69
67
/// Returns a handle to the current task to call `notify` at a later date.
70
68
///
Original file line number Diff line number Diff line change @@ -11,13 +11,9 @@ use std::thread;
11
11
use std:: sync:: { Arc , Mutex } ;
12
12
use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
13
13
14
- fn is_send < T : Send > ( ) { }
15
-
16
- #[ test]
17
- fn bounds ( ) {
18
- is_send :: < mpsc:: Sender < i32 > > ( ) ;
19
- is_send :: < mpsc:: Receiver < i32 > > ( ) ;
20
- }
14
+ trait AssertSend : Send { }
15
+ impl AssertSend for mpsc:: Sender < i32 > { }
16
+ impl AssertSend for mpsc:: Receiver < i32 > { }
21
17
22
18
#[ test]
23
19
fn send_recv ( ) {
Original file line number Diff line number Diff line change @@ -8,14 +8,8 @@ use futures::future;
8
8
use futures:: stream:: FuturesUnordered ;
9
9
use futures:: sync:: oneshot;
10
10
11
- #[ test]
12
- fn bounds ( ) {
13
- fn is_send < T : Send > ( ) { }
14
- fn is_sync < T : Sync > ( ) { }
15
-
16
- is_send :: < FuturesUnordered < ( ) > > ( ) ;
17
- is_sync :: < FuturesUnordered < ( ) > > ( ) ;
18
- }
11
+ trait AssertSendSync : Send + Sync { }
12
+ impl AssertSendSync for FuturesUnordered < ( ) > { }
19
13
20
14
#[ test]
21
15
fn basic_usage ( ) {
You can’t perform that action at this time.
0 commit comments