Hello I'm new to rust. I've been reading the rust book and doing lots of research.
I'm attempting to add a rest API to Mozilla's Project Mentat. I think I've got most of the structure working but I'm running into issues in the query-projector crate.
Here is the first error
error[E0432]: unresolved import `serde`
--> query-projector/src/lib.rs:74:9
|
74 | pub use serde::Serialize;
| ^^^^^ maybe a missing crate `serde`?
The error index: Rust Compiler Error Index indicates that there may be a spelling mestake (checked) some difference due to rust edition (tried setting edition to 2021) no luck. I also double checked the cargo.toml in the query-projector crate.
Serde is an optional dependency; maybe you’ll want to put #[cfg(feature = "serde")] on that pub use … line (or on some module containing it).
Make sure to test whether the crate still works either with or without that feature (specify the feature by including or not including --features serde argument to cargo check or other cargo commands).
In case serde isn’t supposed to be an optional dependency at all, the Cargo.toml should be modified accordingly.
In case the code is still edition 2015, you’d also need to put extern crate serde; somewhere (I believe typically in the root module of the crate). In case of optional dependency, that would also need to be cfg’d, so
#[cfg(feature = "serde")]
extern crate serde;
I suppose. Or without the cfg line if you made the dependency non-optional.