add display
This commit is contained in:
16
single_file_tests/display.rs
Normal file
16
single_file_tests/display.rs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user