How are features used?

I have been reading the section of the cargo book on features, and I am confused. Now I need to use them.

I am using (trying to use...) the crate chrono in a programme being compiled for wasm. To do so I need to compile it with wasmbind feature.

Ok. How? Where in my Cargo.toml do I specify that chrono should be compiled with feature wasmbind?

In the [dependencies] section of Cargo.toml:

chrono = { version = "0.4.19", features = ["wasmbind"] }

Thank you.

If it is possible, can you explain how I could have found out for myself from the Cargo Book?

The Cargo Book documents it very briefly here, using the alternate form of TOML table syntax: Specifying Dependencies - The Cargo Book

Adding more examples to the book would be useful.

1 Like

I concur. The feature feature is used a lot more than what the book might unintentionally imply. More emphasis would be a good thing.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.