mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 09:14:20 +00:00
20 lines
237 B
Rust
20 lines
237 B
Rust
// run-pass
|
|
struct S {
|
|
x: String
|
|
}
|
|
|
|
impl S {
|
|
pub fn foo(self) {
|
|
self.bar();
|
|
}
|
|
|
|
pub fn bar(self) {
|
|
println!("{}", self.x);
|
|
}
|
|
}
|
|
|
|
pub fn main() {
|
|
let x = S { x: "Hello!".to_string() };
|
|
x.foo();
|
|
}
|