Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created April 25, 2018 23:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rust-play/36914d2a4d3893906dc1ed00ab40af76 to your computer and use it in GitHub Desktop.
Save rust-play/36914d2a4d3893906dc1ed00ab40af76 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
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