Skip to content

Instantly share code, notes, and snippets.

@haxpor
Last active March 17, 2022 13:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haxpor/4550270788fdec3d9cc29676c42aa8ed to your computer and use it in GitHub Desktop.
Save haxpor/4550270788fdec3d9cc29676c42aa8ed to your computer and use it in GitHub Desktop.
Rust with cargo on how to run example in the rust project.

Run with cargo run --example <example-name>.

In Cargo.toml, configure it with the following if each example needs special crate's features.

[[example]]
name = "json"
required-features = ["json", "serde/derive"]

wheres "json" is examples/json.rs.

If encounter error in package about needing to enable features, then supply --features= flags e.g. --features="json serde/derive".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment