]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/private-method.rs
auto merge of #6825 : caitp/rust/issue-6824, r=Aatch
[rust.git] / src / test / run-pass / private-method.rs
1 // Copyright 2012 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 use std::uint;
12
13 struct cat {
14     priv meows : uint,
15
16     how_hungry : int,
17 }
18
19 pub impl cat {
20     fn play(&mut self) {
21         self.meows += 1u;
22         self.nap();
23     }
24 }
25
26 priv impl cat {
27     fn nap(&mut self) { for uint::range(1u, 10u) |_i| { }}
28 }
29
30 fn cat(in_x : uint, in_y : int) -> cat {
31     cat {
32         meows: in_x,
33         how_hungry: in_y
34     }
35 }
36
37 pub fn main() {
38   let mut nyan : cat = cat(52u, 99);
39   nyan.play();
40 }