Skip to content

Allow extra fields when using #[from] (using Default trait) #441

@xyzzyz

Description

@xyzzyz

It would be useful to allow extra fields in the structs when using #[from], to optionally add additional context. I think that could be achieved by simply initializing them with Default::default() in the From implementation, and allowing user to add the context to errors later (e.g. with another derive macro from a different crate).

I could provide a PR that implement it, but I saw from some previous issues that you're somewhat against the idea of supporting adding context to the errors, so I want to make sure you're on board with this before I spend more time on it.

I believe that my proposal is minimally intrusive, and maintains the spirit of simplicity of this crate. If this would stray too much from the current interface, how about adding optional parameter to #[from], e.g. #[from(with_defaults)], that would trigger this behavior?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions