(De)-Serialize a Matrix fails in rust-cookbook's playground with the following output:
Compiling playground v0.0.1 (/playground)
error[E0277]: the trait bound `nalgebra::Matrix<i32, nalgebra::Dynamic, nalgebra::Dynamic, nalgebra::VecStorage<i32, nalgebra::Dynamic, nalgebra::Dynamic>>: serde::ser::Serialize` is not satisfied
--> src/main.rs:11:51
|
11 | let serialized_matrix = serde_json::to_string(&matrix)?;
| ^^^^^^^ the trait `serde::ser::Serialize` is not implemented for `nalgebra::Matrix<i32, nalgebra::Dynamic, nalgebra::Dynamic, nalgebra::VecStorage<i32, nalgebra::Dynamic, nalgebra::Dynamic>>`
|
::: /playground/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_json-1.0.53/src/ser.rs:2224:17
|
2224 | T: ?Sized + Serialize,
| --------- required by this bound in `serde_json::to_string`
error[E0277]: the trait bound `nalgebra::Matrix<i32, nalgebra::Dynamic, nalgebra::Dynamic, nalgebra::VecStorage<i32, nalgebra::Dynamic, nalgebra::Dynamic>>: serde::de::Deserialize<'_>` is not satisfied
--> src/main.rs:14:45
|
14 | let deserialized_matrix: DMatrix<i32> = serde_json::from_str(&serialized_matrix)?;
| ^^^^^^^^^^^^^^^^^^^^ the trait `serde::de::Deserialize<'_>` is not implemented for `nalgebra::Matrix<i32, nalgebra::Dynamic, nalgebra::Dynamic, nalgebra::VecStorage<i32, nalgebra::Dynamic, nalgebra::Dynamic>>`
|
::: /playground/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_json-1.0.53/src/de.rs:2397:8
|
2397 | T: de::Deserialize<'a>,
| ------------------- required by this bound in `serde_json::from_str`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.
error: could not compile `playground`.
To learn more, run the command again with --verbose.
The same code, using the same Cargo.toml, works perfectly fine on my machine. Am not sure what's going on...?!
(De)-Serialize a Matrix fails in
rust-cookbook
's playground with the following output:The same code, using the same
Cargo.toml
, works perfectly fine on my machine. Am not sure what's going on...?!