How can I write a displaydoc impl for the following struct?
#[displaydoc("{kind}: {str_context}")]
pub struct DataError {
/// Broad category of the error.
pub kind: DataErrorKind,
/// Additional context, if available.
pub str_context: Option<&'static str>,
}
This errors out with:
`std::option::Option<&str>` cannot be formatted with the default formatter
What I would like is to make an error that contains ": {str_context}" when Some and nothing when None.
Do I need to manually implement Display, or can I use displaydoc?
How can I write a displaydoc impl for the following struct?
This errors out with:
What I would like is to make an error that contains
": {str_context}"when Some and nothing when None.Do I need to manually implement Display, or can I use displaydoc?