dtolnay / typetag

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

can't derive Deserialize to struct which has a Rc<RefCell<dyn trait>> #77

Closed Woodman3 closed 6 months ago

Woodman3 commented 7 months ago
    use serde::{Deserialize, Serialize};
    use std::rc::Rc;
    use std::cell::RefCell;
    #[typetag::serde(tag="type")]
    pub trait Unit:std::fmt::Debug{}

    #[derive(Serialize,Deserialize)]
    // struct Teststruct(Rc<dyn Unit>); // it can complie
    struct Teststruct(Rc<RefCell<dyn Unit>>); //it can't complie