Open chilabot opened 1 year ago
I'd be nice to have 'init-only' fields, so you can use them in field initialization:
#[derive(new)] struct Test { #[new(init)] // <--- active: bool, #[new(value = "Other::new(active)")] other: Other }
Like https://docs.python.org/3/library/dataclasses.html#init-only-variables
I don't think I'd add too much complexity and I'd be really useful. The workaround for this is to declare the init-field after 'other' and to store it in the struct, which also forces a copy if the initialized class takes the parameter by value.
I'd be nice to have 'init-only' fields, so you can use them in field initialization:
Like https://docs.python.org/3/library/dataclasses.html#init-only-variables
I don't think I'd add too much complexity and I'd be really useful. The workaround for this is to declare the init-field after 'other' and to store it in the struct, which also forces a copy if the initialized class takes the parameter by value.