You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How it's supposed to work? What's the logic behind {_variant} here? Why you're implying it should be something like #[display("{a}, {b:x}, ..., {z}")]?
We can theoretically support intermediate transformation of the field:
#[display("{:x}")]
b: u32,
But you still somehow should refer whether to include this into the final fmt representation.
@tyranron Sorry, it's just my rough idea which is somewhat lacking, more detailed example here:
#[derive(Display)]// The _fields here is reserved like _variant, which is string array like `Vec<&str>` , // and the items is formatted by the macro `#[display("{_variant}")]` or `#[display("{:x}")]`
#[display(fmt = "all fields:{}, total:{}", _fields.join(","), _fields.len())// Default field display
#[display("{_variant}")]structA{
a:u32,// Special field display
#[display("{:x}")]
b:u32,
...,
z:u32}
I have a struct which contains many fields and some of these fields (like
b
) need to display in Hex:but
#[display("{a}, {b:x}, ..., {z}")]
is long and verbose, how to use placeholder for struct?I wish to use placeholder like enum:
The text was updated successfully, but these errors were encountered: