• 0 Posts
  • 36 Comments
Joined 1 year ago
cake
Cake day: July 23rd, 2023

help-circle
  • 404@lemmy.ziptoRust@programming.devstruct in Rust
    link
    fedilink
    English
    arrow-up
    7
    ·
    1 day 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)… :)






  • I was looking for a mouse recently. My priorities were:

    • Comfortable (i.e. vertical; after getting used to it I’m not looking back)
    • Standard format replaceable battery, since built-ins always end up depleting or swelling and being hard to replace
    • Nice scroll wheel (highly subjective though)
    • Easy switching between Linux and Windows systems
    • Small-ish, portable

    I got the Logitech Lift. I am pleasantly surprised by how nice it is.

    Granted I mostly use my mouse for browsing, scrolling and navigating UIs. The rest is all keyboard. For games I prefer controllers and game pads so precision/high performance wasn’t an issue for me at all.