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? #81

Closed makorne closed 2 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!!

dtolnay commented 2 months ago

Hi @makorne, sorry that no one was able to provide guidance here. If you have not figured this out so far, you could try taking this question to any of the resources shown in https://www.rust-lang.org/community.