Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

rust - Can tests be built in release mode using Cargo?

I'm using cargo build --release to build my project in release configuration and cargo test to build and run my tests.

However, I'd like to also build my tests in release mode; can this be done using cargo?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

cargo test --release exists, but it is slightly different than just enabling optimizations. For example, debug assertions become disabled.

You can also set opt-level in the [profile.test] section of your Cargo.toml, as Viktor Dahl suggests.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...