2025-06-09 02:16:25 +05:00
|
|
|
//! Test implementing methods for types defined in other modules
|
|
|
|
|
|
2019-07-27 00:54:25 +03:00
|
|
|
//@ run-pass
|
|
|
|
|
|
2014-09-10 22:26:41 -07:00
|
|
|
mod foo {
|
2015-02-20 08:17:05 +02:00
|
|
|
pub struct Point {
|
|
|
|
|
pub x: i32,
|
2024-02-20 21:20:14 +01:00
|
|
|
#[allow(dead_code)]
|
2015-02-20 08:17:05 +02:00
|
|
|
pub y: i32,
|
2014-09-10 22:26:41 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-20 08:17:05 +02:00
|
|
|
impl foo::Point {
|
|
|
|
|
fn x(&self) -> i32 { self.x }
|
2014-09-10 22:26:41 -07:00
|
|
|
}
|
|
|
|
|
|
2015-02-20 08:17:05 +02:00
|
|
|
fn main() {
|
|
|
|
|
assert_eq!((foo::Point { x: 1, y: 3}).x(), 1);
|
|
|
|
|
}
|