Skip to content

Chapter 3 - Section Real World Applications - Cargo.toml dependency for serde needs text for feature "derive" #4

@glafrance

Description

@glafrance

In chapter 3, in the section entitled "Real-World Applications", it indicates we must add this to our dependencies in Cargo.toml:

[dependencies]
serde = "1.0"
serde_json = "1.0"

But for the code to run it should be:

[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

Without these changes cargo build gives errors, such as:

error: cannot find derive macro `Serialize` in this scope
 --> src/main.rs:4:10
  |
4 | #[derive(Serialize, Deserialize, Debug)]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions