dtolnay / typetag

Serde serializable and deserializable trait objects
Apache License 2.0
1.19k stars 38 forks source link

How to change the values of structures? #80

Closed makorne closed 3 months ago

makorne commented 3 months ago

Hi! Thank you for your great crates!!!

But how to change the values of structures? For example set: click.x = 15

    let click = Click { x: 10, y: 10 };
    let event = &click as &dyn WebEvent;
    let json = serde_json::to_string(event)?;
    println!("Click json: {}", json);
    let mut de: Box<dyn WebEvent> = serde_json::from_str(&json)?;
    de.inspect();
    de.x = 15;
       ^ unknown field

Thanks!!