This commit is contained in:
Pascal Engélibert 2024-03-15 20:15:21 +01:00
commit 7c73d32ffa
5 changed files with 32 additions and 44 deletions

View file

@ -14,7 +14,7 @@
//!
//! In doc comments, _N_ represents the number of samples, _D_ represents the number of different values taken by the samples.
#![cfg_attr(feature = "nostd", no_std)]
#![cfg_attr(not(feature = "std"), no_std)]
mod traits;
@ -34,7 +34,7 @@ pub struct MedianAcc<
_t: core::marker::PhantomData<T>,
}
#[cfg(not(feature = "nostd"))]
#[cfg(feature = "std")]
pub mod vec {
pub type MedianAcc<T> = crate::MedianAcc<T, Vec<(T, u32)>>;
}
@ -213,6 +213,7 @@ mod tests {
use rand::Rng;
#[cfg(feature = "std")]
fn naive_median<T: Clone + Ord>(samples: &mut [T]) -> Option<MedianResult<T>> {
if samples.is_empty() {
None
@ -232,6 +233,7 @@ mod tests {
}
}
#[cfg(feature = "std")]
#[test]
fn correctness() {
let mut rng = rand::thread_rng();
@ -249,6 +251,7 @@ mod tests {
}
}
#[cfg(feature = "smallvec")]
#[test]
fn correctness_smallvec() {
let mut rng = rand::thread_rng();

View file

@ -9,7 +9,7 @@ pub trait InsertIndex: cc_traits::Collection {
) -> Self::Output;
}
#[cfg(not(feature = "nostd"))]
#[cfg(feature = "std")]
impl<T> InsertIndex for Vec<T> {
type Output = ();