This repository was archived by the owner on May 23, 2024. It is now read-only.
File tree 5 files changed +92
-0
lines changed
5 files changed +92
-0
lines changed Original file line number Diff line number Diff line change
1
+ pub trait Trait1 {
2
+ type C ;
3
+ }
4
+
5
+ struct T1 ;
6
+ impl Trait1 for T1 {
7
+ type C = usize ;
8
+ }
9
+ pub trait Callback < T : Trait1 > : FnMut ( <T as Trait1 >:: C ) { }
10
+ impl < T : Trait1 , F : FnMut ( <T as Trait1 >:: C ) > Callback < T > for F { }
11
+
12
+ pub struct State < T : Trait1 > {
13
+ callback : Option < Box < dyn Callback < T > > > ,
14
+ }
15
+ impl < T : Trait1 > State < T > {
16
+ fn new ( ) -> Self {
17
+ Self { callback : None }
18
+ }
19
+ fn test_cb ( & mut self , d : <T as Trait1 >:: C ) {
20
+ ( self . callback . as_mut ( ) . unwrap ( ) ) ( d)
21
+ }
22
+ }
23
+
24
+ fn main ( ) {
25
+ let mut s = State :: < T1 > :: new ( ) ;
26
+ s. test_cb ( 1 ) ;
27
+ }
Original file line number Diff line number Diff line change
1
+ #![ allow( incomplete_features) ]
2
+ #![ feature( type_alias_impl_trait) ]
3
+ #![ feature( impl_trait_in_bindings) ]
4
+
5
+ type FooArg < ' a > = & ' a dyn ToString ;
6
+ type FooRet = impl std:: fmt:: Debug ;
7
+
8
+ type FooItem = Box < dyn Fn ( FooArg ) -> FooRet > ;
9
+ type Foo = impl Iterator < Item = FooItem > ;
10
+
11
+ #[ repr( C ) ]
12
+ struct Bar ( u8 ) ;
13
+
14
+ impl Iterator for Bar {
15
+ type Item = FooItem ;
16
+
17
+ fn next ( & mut self ) -> Option < Self :: Item > {
18
+ Some ( Box :: new ( quux) )
19
+ }
20
+ }
21
+
22
+ fn quux ( st : FooArg ) -> FooRet {
23
+ Some ( st. to_string ( ) )
24
+ }
25
+
26
+ fn ham ( ) -> Foo {
27
+ Bar ( 1 )
28
+ }
29
+
30
+ fn oof ( ) -> impl std:: fmt:: Debug {
31
+ let mut bar = ham ( ) ;
32
+ let func = bar. next ( ) . unwrap ( ) ;
33
+ return func ( & "oof" ) ;
34
+ }
35
+
36
+ fn main ( ) {
37
+ println ! ( "{:?}" , oof( ) ) ;
38
+ }
Original file line number Diff line number Diff line change
1
+ struct S ;
2
+
3
+ fn main ( ) {
4
+ & ( [ S ] [ 0 ] , ) ;
5
+ }
Original file line number Diff line number Diff line change
1
+ #![ allow( incomplete_features) ]
2
+ #![ feature( impl_trait_in_bindings) ]
3
+
4
+ fn main ( ) {
5
+ let ref _x: impl Sized = 5 ;
6
+ }
Original file line number Diff line number Diff line change
1
+ use std:: sync:: atomic:: { AtomicPtr , Ordering } ;
2
+
3
+ const P : & dyn T = & S as & dyn T ;
4
+ static mut LOGGER : AtomicPtr < & dyn T > = AtomicPtr :: new ( & mut P ) ;
5
+
6
+ pub trait T { }
7
+ struct S ;
8
+ impl T for S { }
9
+
10
+ pub fn f ( ) {
11
+ match * LOGGER . load ( Ordering :: SeqCst ) {
12
+ P | _ => { }
13
+ }
14
+ }
15
+
16
+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments