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
error: deriving From requires no fields other than source and backtrace
--> src/lib.rs:26:9
|
26 | #[from]
| ^^^^^^^
However, there is a pretty reasonable implementation of From<tera::Error> for Error: make this extra field path be constructed with None. Something like:
I could implement it manually, but it feels like it's a work that the procedural macro could be doing. Not only in my situation, but also in many similar situations, From could be automatically implemented constructing extra fields with some given default values. I'd propose this API:
And also, to improve ergonomics, if the default value is omitted from the attribute, the proc-macro could generate Default::default() as the constructed value. For instance, since None == Default::default(), the code above would be equivalent to the code below:
I intend to implement this myself if I find some time to do it, but I need feedback first. Is this feature welcome? If I open a PR with this, would it be welcome?
The text was updated successfully, but these errors were encountered:
I am facing this situation:
Which yields this error:
However, there is a pretty reasonable implementation of
From<tera::Error> for Error
: make this extra fieldpath
be constructed withNone
. Something like:I could implement it manually, but it feels like it's a work that the procedural macro could be doing. Not only in my situation, but also in many similar situations,
From
could be automatically implemented constructing extra fields with some given default values. I'd propose this API:And also, to improve ergonomics, if the default value is omitted from the attribute, the proc-macro could generate
Default::default()
as the constructed value. For instance, sinceNone == Default::default()
, the code above would be equivalent to the code below:I intend to implement this myself if I find some time to do it, but I need feedback first. Is this feature welcome? If I open a PR with this, would it be welcome?
The text was updated successfully, but these errors were encountered: