Debug
interface Debug
The Debug
interface is used to inspect a value to help with debugging.
This will used to string interpolate the value in a debug context: {var:?}
.
You can implement this interface for your own types to provide a custom debug representation.
For example:
nv
struct User {
name: string,
}
impl Debug for User {
pub fn inspect(self): string {
return `User { name: ${self.name} }`;
}
}
let user = User { name: "Alice" };
assert_eq user.inspect(), "User { name: Alice }";
assert_eq `${user:?}`, user.inspect();
Methods