Created
April 25, 2018 23:39
-
-
Save rust-play/36914d2a4d3893906dc1ed00ab40af76 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::fmt; | |
struct Rect { | |
width: f32, | |
height: f32, | |
} | |
impl fmt::Display for Rect { | |
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | |
write!(f, "Rect[width: {}; height: {}]", | |
self.width, self.height) | |
} | |
} | |
fn main() { | |
let c = Rect{width: 2.0, height: 5.0}; | |
println!("c = {}", c); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment