44Igor44
@44Igor44
Охотник за вопросами

Проблема использования #[test_case] в rust?

Я имею участок кода:
#[feature(custom_test_frameworks)]

#[test_runner(crate::test_runner)]
#[cfg(test)]
fn test_runner(tests: &[&dyn Fn()]) {
    println!("Starting {} tests", tests.len());
    for test in tests {
        test();
    }
}
#[reexport_test_harness_main = "test_main"]
#[test_case]
fn trivial_assertion() {
    print!("trivial assertion... ");
    assert_eq!(1, 1);
    println!("[completed]");
}

но почему то не работает #[feature(custom_test_frameworks)] :

error[E0658]: use of unstable library feature 'custom_test_frameworks': custom test frameworks are an unstable feature
--> src\main.rs:30:3
|
30 | #[test_case]
| ^^^^^^^^^
|
= note: see issue #50297 for more information
= help: add `#![feature(custom_test_frameworks)]` to the crate attributes to enable

For more information about this error, try `rustc --explain E0658`.

как исправить?
  • Вопрос задан
  • 59 просмотров
Решения вопроса 1
bingo347
@bingo347
Crazy on performance...
Вам же явно написали:#![feature(custom_test_frameworks)]

Атрибуты вида #[something] применяются к айтему под ними, атрибуты вида #![something] - к айтему в котором они находятся (должны находится в самом верху).
https://doc.rust-lang.org/reference/attributes.html

Ну и еще, feature работает только в nightly тулчейне.
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы