Add an Option to use a Format String to Structs
ModProg opened this issue · comments
My Idea is to use something similar to thiserror
where you specify a format string that get's filled with the fields:
#[derive(Error, Debug)]
pub enum DocumentError {
#[error("Invalid {0}: `{1}`")]
InvalidAttribute(String, String),
}
This could look like this for Debug of structs:
#[derive(Derivative)]
#[derivative(Debug(format="({x},{y}: {w})"))]
pub struct Point {
pub x: f32,
pub y: f32,
pub w: f32,
}
I think most of the Time this is enough for formatting, and you don't actually need a function for that.