File tree 2 files changed +43
-2
lines changed
run-make/extern-fn-with-packed-struct
2 files changed +43
-2
lines changed Original file line number Diff line number Diff line change 8
8
// option. This file may not be copied, modified, or distributed
9
9
// except according to those terms.
10
10
11
+ use std:: fmt;
12
+
11
13
#[ repr( packed) ]
12
- #[ derive( Copy , Clone , PartialEq , Debug ) ]
14
+ #[ derive( Copy , Clone ) ]
13
15
struct Foo {
14
16
a : i8 ,
15
17
b : i16 ,
16
18
c : i8
17
19
}
18
20
21
+ impl PartialEq for Foo {
22
+ fn eq ( & self , other : & Foo ) -> bool {
23
+ self . a == other. a && self . b == other. b && self . c == other. c
24
+ }
25
+ }
26
+
27
+ impl fmt:: Debug for Foo {
28
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
29
+ let a = self . a ;
30
+ let b = self . b ;
31
+ let c = self . c ;
32
+
33
+ f. debug_struct ( "Foo" )
34
+ . field ( "a" , & a)
35
+ . field ( "b" , & b)
36
+ . field ( "c" , & c)
37
+ . finish ( )
38
+ }
39
+ }
40
+
19
41
#[ link( name = "test" , kind = "static" ) ]
20
42
extern {
21
43
fn foo ( f : Foo ) -> Foo ;
Original file line number Diff line number Diff line change 8
8
// option. This file may not be copied, modified, or distributed
9
9
// except according to those terms.
10
10
11
+ use std:: fmt;
11
12
use std:: mem;
12
13
13
14
#[ repr( packed) ]
14
- #[ derive( Copy , Clone , PartialEq , Debug ) ]
15
+ #[ derive( Copy , Clone ) ]
15
16
struct Foo {
16
17
bar : u8 ,
17
18
baz : u64
18
19
}
19
20
21
+ impl PartialEq for Foo {
22
+ fn eq ( & self , other : & Foo ) -> bool {
23
+ self . bar == other. bar && self . baz == other. baz
24
+ }
25
+ }
26
+
27
+ impl fmt:: Debug for Foo {
28
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
29
+ let bar = self . bar ;
30
+ let baz = self . baz ;
31
+
32
+ f. debug_struct ( "Foo" )
33
+ . field ( "bar" , & bar)
34
+ . field ( "baz" , & baz)
35
+ . finish ( )
36
+ }
37
+ }
38
+
20
39
pub fn main ( ) {
21
40
let foos = [ Foo { bar : 1 , baz : 2 } ; 10 ] ;
22
41
You can’t perform that action at this time.
0 commit comments