我在用Rust写一个不依赖于std的crate,并设置target = "x86_64-unknown-uefi"。但是测试脚本(cargo test)需要依赖std,我该如何去配置?
.cargo/config代码如下:
[build]
target = "x86_64-unknown-uefi"
[unstable]
build-std = ["core", "alloc"]
build-std-features = ["compiler-builtins-mem"]
example.rs代码如下:
#![cfg_attr(not(test), no_std)]
#![allow(dead_code)]
fn main() {
}
#[cfg(test)]
mod test {
#[test]
fn a() {
println!("Hello, world!");
}
}
现在需要执行cargo test命令以成功执行测试函数a