Home

No Derive Feature Error In Rust

The below if fixed by adding the derive feature to serde like:

toml
serde = { version = "1.0.195", features = ["derive"] }
error: cannot find derive macro ``Deserialize`` in this scope
  --> _active_nvim_run:11:17
   |
11 | #[derive(Debug, Deserialize)]
   |                 ^^^^^^^^^^^
   |
note: ``Deserialize`` is imported here, but it is only a trait, without a derive macro
  --> _active_nvim_run:8:13
   |
8  | use serde::{Deserialize, Serialize};
   |             ^^^^^^^^^^^

warning: unused import: `Serialize`
 --> _active_nvim_run:8:26
  |
8 | use serde::{Deserialize, Serialize};
  |                          ^^^^^^^^^
  |
  = note: ``#[warn(unused_imports)]`` on by default

error[E0277]: the trait bound ``Widget: Deserialize<'_>`` is not satisfied
    --> _active_nvim_run:18:22
     |
18   |   let data: Widget = serde_json::from_str(json_string).unwrap();
     |                      ^^^^^^^^^^^^^^^^^^^^ the trait ``Deserialize<'_>`` is not implemented for `Widget`
     |
     = help: the following other types implement trait `Deserialize<'de>`:
               bool
               char
               isize
               i8
               i16
               i32
               i64
               i128
             and 130 others
note: required by a bound in `serde_json::from_str`
    --> /Users/alan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde_json-1.0.111/src/de.rs:2676:8
     |
2674 | pub fn from_str<'a, T>(s: &'a str) -> Result<T>
     |        -------- required by a bound in this function
2675 | where
2676 |     T: de::Deserialize<'a>,
     |        ^^^^^^^^^^^^^^^^^^^ required by this bound in `from_str`

For more information about this error, try `rustc --explain E0277`.
error: could not compile ``_active_nvim_run`` (bin "_active_nvim_run") due to 2 previous errors; 1 warning emitted
~ fin ~