16 lines
237 B
Rust
16 lines
237 B
Rust
use std::fmt;
|
|
|
|
struct X {
|
|
i: i32,
|
|
}
|
|
|
|
impl fmt::Display for X {
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
write!(f, "Hello: {}", self.i)
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
let x = X { i: 111, };
|
|
println!("{}", x);
|
|
} |