4 ms·
Because converting a type to a string isn't trivial. It needs to be defined for that type. Rust does have a pair of traits that can be used, Display [1] and De
by unlinked_dll 7y ago
Because converting a type to a string isn't trivial. It needs to be defined for that type.
Rust does have a pair of traits that can be used, Display [1] and Debug [2]. Display must be implemented manually by the author of a type, while Debug can be automatically derived if all the members of a type implement Debug. Like this:
#[derive(Debug)]
struct Foo {
}
[1] https://doc.rust-lang.org/std/fmt/trait.Display.html https://doc.rust-lang.org/std/fmt/trait.Display.html
[2] https://doc.rust-lang.org/std/fmt/trait.Debug.html https://doc.rust-lang.org/std/fmt/trait.Debug.html