Closed rnbguy closed 1 week ago
Probably need a pass through clippy::std_instead_of_core
and clippy::std_instead_of_alloc
lints :slightly_smiling_face:
Unfortunately I have no time to look on it.
I am happy to make a PR. :slightly_smiling_face: but, can I expect a quick release with it ? :pray:
If you provide a PR I'll review and add it ASAP
Just a note: you have a workaround here:
// lib.rs
#![no_std]
pub fn add(left: u64, right: u64) -> u64 {
left + right
}
#[cfg(test)]
mod tests {
use super::*;
use rstest::rstest;
use ::core as std;
#[rstest]
#[case("2", "2", "4")]
fn it_works(#[case] left: u64, #[case] right: u64, #[case] expected: u64) {
assert_eq!(add(left, right), expected);
}
}
Or better
// lib.rs
#![no_std]
#![cfg(test)]
extern crate std;
pub fn add(left: u64, right: u64) -> u64 {
left + right
}
#[cfg(test)]
mod tests {
use super::*;
use rstest::rstest;
#[rstest]
#[case("2", "2", "4")]
fn it_works(#[case] left: u64, #[case] right: u64, #[case] expected: u64) {
assert_eq!(add(left, right), expected);
}
}
Even if your crate is a no_std
one the tests are compiled with std support (they run in multi threading environment and is sure that they have std support). That means in your library your code cannot use std
directly because the #![no_std]
attribute remove this crate from the resolution but when you compile test the std binary is present.
So, we can just just take care that the rendered code use core
instead std
if it's possible, but the rstest
library can still remain in std
mode because it will be compiled with the std support and executed in a std environment.
I'll add these notes in the PR also.
The following tests fails to compile
because this is how it is expanded,
rstest
could have usedcore::marker::PhantomData
.