File tree Expand file tree Collapse file tree 3 files changed +70
-0
lines changed Expand file tree Collapse file tree 3 files changed +70
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ fn main ( ) {
12
+ let mut t = [ 1 ; 2 ] ;
13
+ t = [ t[ 1 ] * 2 , t[ 0 ] * 2 ] ;
14
+ assert_eq ! ( & t[ ..] , & [ 2 , 2 ] ) ;
15
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ struct A {
12
+ pub x : u32 ,
13
+ pub y : u32 ,
14
+ }
15
+
16
+ fn main ( ) {
17
+ let mut a = A { x : 1 , y : 1 } ;
18
+ a = A { x : a. y * 2 , y : a. x * 2 } ;
19
+ assert_eq ! ( a. x, 2 ) ;
20
+ assert_eq ! ( a. y, 2 ) ;
21
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ #[ derive( Debug ) ]
12
+ enum Foo {
13
+ Bar ( u32 , u32 ) ,
14
+ Baz ( & ' static u32 , & ' static u32 )
15
+ }
16
+
17
+ static NUM : u32 = 100 ;
18
+
19
+ fn main ( ) {
20
+ let mut b = Foo :: Baz ( & NUM , & NUM ) ;
21
+ b = Foo :: Bar ( f ( & b) , g ( & b) ) ;
22
+ }
23
+
24
+ static FNUM : u32 = 1 ;
25
+
26
+ fn f ( b : & Foo ) -> u32 {
27
+ FNUM
28
+ }
29
+
30
+ static GNUM : u32 = 2 ;
31
+
32
+ fn g ( b : & Foo ) -> u32 {
33
+ GNUM
34
+ }
You can’t perform that action at this time.
0 commit comments