]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/issue-3753.rs
Merge branch 'master' into cfg_tmp_dir
[rust.git] / src / test / run-pass / issue-3753.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 // Issue #3656
12 // Issue Name: pub method preceeded by attribute can't be parsed
13 // Abstract: Visibility parsing failed when compiler parsing
14
15 use std::f64;
16
17 pub struct Point {
18     x: f64,
19     y: f64
20 }
21
22 impl Copy for Point {}
23
24 pub enum Shape {
25     Circle(Point, f64),
26     Rectangle(Point, Point)
27 }
28
29 impl Copy for Shape {}
30
31 impl Shape {
32     pub fn area(&self, sh: Shape) -> f64 {
33         match sh {
34             Shape::Circle(_, size) => f64::consts::PI * size * size,
35             Shape::Rectangle(Point {x, y}, Point {x: x2, y: y2}) => (x2 - x) * (y2 - y)
36         }
37     }
38 }
39
40 pub fn main(){
41     let s = Shape::Circle(Point { x: 1.0, y: 2.0 }, 3.0);
42     println!("{}", s.area(s));
43 }