]> git.lizzy.rs Git - rust.git/blob - src/test/auxiliary/method_self_arg1.rs
Rollup merge of #28991 - goyox86:goyox86/rustfmting-liblog-II, r=alexcrichton
[rust.git] / src / test / auxiliary / method_self_arg1.rs
1 // Copyright 2014 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 #![crate_type = "lib"]
12
13 #![allow(unknown_features)]
14 #![feature(box_syntax)]
15
16 static mut COUNT: u64 = 1;
17
18 pub fn get_count() -> u64 { unsafe { COUNT } }
19
20 #[derive(Copy, Clone)]
21 pub struct Foo;
22
23 impl Foo {
24     pub fn foo(self, x: &Foo) {
25         unsafe { COUNT *= 2; }
26         // Test internal call.
27         Foo::bar(&self);
28         Foo::bar(x);
29
30         Foo::baz(self);
31         Foo::baz(*x);
32
33         Foo::qux(box self);
34         Foo::qux(box *x);
35     }
36
37     pub fn bar(&self) {
38         unsafe { COUNT *= 3; }
39     }
40
41     pub fn baz(self) {
42         unsafe { COUNT *= 5; }
43     }
44
45     pub fn qux(self: Box<Foo>) {
46         unsafe { COUNT *= 7; }
47     }
48 }