I have a struct that, as soon as I add interior mutability to it through Rc<RefCell<...>>
results in a compilation error:
error[E0277]: the trait bound `Rc<RefCell<Vec<UserDataExportUserItem>>>: websocket_server::_::_serde::Serialize` is not satisfied
--> src/services/users/user_data_export/models.rs:22:17
|
22 | #[derive(Debug, Serialize)]
| ^^^^^^^^^ the trait `websocket_server::_::_serde::Serialize` is not implemented for `Rc<RefCell<Vec<UserDataExportUserItem>>>`
...
26 | items: Rc<RefCell<Vec<UserDataExportUserItem>>>,
| ----- required by a bound introduced by this call
|
= help: the following other types implement trait `websocket_server::_::_serde::Serialize`:
bool
char
isize
i8
i16
i32
i64
i128
and 2373 others
note: required by a bound in `websocket_server::_::_serde::ser::SerializeStruct::serialize_field`
--> /home/remi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde-1.0.197/src/ser/mod.rs:1865:12
|
1859 | fn serialize_field<T: ?Sized>(
| --------------- required by a bound in this associated function
...
1865 | T: Serialize;
| ^^^^^^^^^ required by this bound in `SerializeStruct::serialize_field`
Some observations:
- It's weird that the error considers that the serde module lives in
websocket_server
, which is one of my crate's modules. It's as if Serde's dependency was resolved as a transitive dependency. - I have confirmed that this should work, both by checking the PR that made Serde compatible with interior mutability types, and by replicating my code in the playground.
Since it doesn't fail in the playground, it means that the problem is specific to my project.
Does anyone have any ideas on what's going on?