mirror of
https://github.com/rust-lang/rust.git
synced 2025-10-02 18:27:37 +00:00
20 lines
310 B
Rust
20 lines
310 B
Rust
//! Test implementing methods for types defined in other modules
|
|
|
|
//@ run-pass
|
|
|
|
mod foo {
|
|
pub struct Point {
|
|
pub x: i32,
|
|
#[allow(dead_code)]
|
|
pub y: i32,
|
|
}
|
|
}
|
|
|
|
impl foo::Point {
|
|
fn x(&self) -> i32 { self.x }
|
|
}
|
|
|
|
fn main() {
|
|
assert_eq!((foo::Point { x: 1, y: 3}).x(), 1);
|
|
}
|