Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUST

rust implement debug for struct

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 by doc.rust-lang.org #
 
PREVIOUS NEXT
Tagged: #rust #implement #debug #struct
ADD COMMENT
Topic
Name
9+6 =