How do you enable a Rust “crate feature”?

前端 未结 1 2009
夕颜
夕颜 2020-11-30 13:31

I\'m trying to use rand::SmallRng. The documentation says

This PRNG is feature-gated: to use, you must enable the crate feature

相关标签:
1条回答
  • 2020-11-30 14:17

    Specify the dependencies in Cargo.toml like so:

    [dependencies]
    rand = { version = "0.7.2", features = ["small_rng"] }
    

    Alternatively:

    [dependencies.rand]
    version = "0.7.2"
    features = ["small_rng"]
    

    Both work.

    0 讨论(0)
提交回复
热议问题