Understanding Rust's `core::fmt` Traits for Custom Struct Formatting
I'm updating my dependencies and I'm getting frustrated with I'm writing unit tests and I'm trying to implement custom formatting for my struct in Rust using the `core::fmt` traits, but I'm running into an scenario where the output is not what I expect... I'm working with Rust version 1.70.0 and have defined a struct `Point` as follows: ```rust struct Point { x: f64, y: f64, } ``` I want to implement the `Display` trait to print the coordinates in a formatted string like `(x, y)`. Here's my implementation: ```rust use core::fmt; impl fmt::Display for Point { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "({}, {})", self.x, self.y) } } ``` When I try to use it in my `main` function: ```rust fn main() { let p = Point { x: 1.0, y: 2.0 }; println!("Point: {}", p); } ``` I get the following behavior message: `behavior[E0277]: the trait bound `Point: std::fmt::Display` is not satisfied`. I’ve double-checked that I've imported `core::fmt`, so I'm puzzled why I'm getting this behavior. I suspect it might have to do with the `core` library's limitations or how I'm using it in a `no_std` environment, as I'm targeting embedded systems. I tried replacing `core::fmt` with `std::fmt`, but that leads to a compilation failure since my environment doesn't support the standard library. Is there a workaround or best practice for implementing custom formatting for structs without using the standard library? Any insights on what I might be missing would be greatly appreciated! This is happening in both development and production on macOS. What's the best practice here? I'm developing on Windows 10 with Rust. Hoping someone can shed some light on this.