Rust Implement Debug For Struct

[Solved] Rust Implement Debug For Struct | Rust - Code Explorer | yomemimo.com
Question : rust implement debug for struct

Answered by : zwazel

struct Point { x: i32, y: i32,
}
impl fmt::Debug for Point { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Point") .field("x", &self.x) .field("y", &self.y) .finish() }
}

Source : https://doc.rust-lang.org/std/fmt/trait.Debug.html | Last Update : Mon, 04 Apr 22

Answers related to rust implement debug for struct

Code Explorer Popular Question For Rust