• 0 Posts
  • 126 Comments
Joined 2 years ago
cake
Cake day: July 23rd, 2023

help-circle











  • What? The US military uses 24 for just one minute? Seems so unnecessary. Why would they do that?

    World     US military
    
    HH:MM:SS  HH:MM:SS
    23:59:59  23:59:59
    00:00:00  24:00:00
    00:00:01  24:00:01
    00:00:02  24:00:02
    ...         ...
    00:00:59  24:00:59
    00:01:00  00:01:00
    00:01:01  00:01:01
    

    Really? Do they order custom clocks for this etc? Do they have custom settings on their computers to add that extra minute?

    Edit: It says in the time chart on the site you linked that 00:00 = 12 am. What are you on about?





  • 404@lemmy.ziptoRust@programming.devstruct in Rust
    link
    fedilink
    English
    arrow-up
    11
    ·
    2 months ago

    You can implement Display for custom structs, to print them in the regular manner:

    use std::fmt;
    
    struct Point {
        x: i32,
        y: i32,
    }
    
    impl fmt::Display for Point {
        fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
            write!(f, "({}, {})", self.x, self.y)
        }
    }
    
    fn main() {
        let point = Point { x: 10, y: 20 };
        println!("{}", point); // using standard println!
    }
    

    You can also implement things like Add, Sub, AddAssign (point_a += point_b)… :)