#[derive(From)]
struct Example {
main_field: u32,
some_extra: bool,
}
Currently, the code above produces impl From<(u32, bool)>. There is no way, AFAIK, to make derive_more create an impl From<u32> instead, with some_extra being set to Default::default().
It would make sense to permit this by using either #[from] or #[from(ignore)]:
#[derive(From)]
struct Example {
#[from]
main_field: u32,
some_extra: bool,
}
#[derive(From)]
struct Example {
main_field: u32,
#[from(ignore)]
some_extra: bool,
}
For fields that were ignored this way, the From impl would use their default values when performing the conversion.
The requirement for those fields to implement Default doesn't seem particularly onerous but it could nevertheless be lifted as well, similarly to how serde does it:
fn true_() -> bool { true }
#[derive(From)]
struct Item {
data: String,
#[from(default = "true_")]
alive: bool,
Currently, the code above produces
impl From<(u32, bool)>. There is no way, AFAIK, to make derive_more create animpl From<u32>instead, withsome_extrabeing set toDefault::default().It would make sense to permit this by using either
#[from]or#[from(ignore)]:For fields that were ignored this way, the
Fromimpl would use their default values when performing the conversion.The requirement for those fields to implement
Defaultdoesn't seem particularly onerous but it could nevertheless be lifted as well, similarly to how serde does it: