I have the following struct
struct S {
value: f32,
square: f32,
}
I would like to derive square from value in the new(value):
impl S {
fn new(value: f32) -> Self {
Self { value, square: value.powi(2) }
}
}
Can I use value field only to serialize the struct and use new(value) to deserialize the whole thing without manually implementing Serialize/Deserialize traits?