Move some test-only code to test files

This also relaxes the bounds on some structs and moves them to the impl
block instead.
This commit is contained in:
Joshua Nelson
2021-03-17 10:28:52 -04:00
parent 5c6d3bf389
commit 620ecc01a2
8 changed files with 85 additions and 78 deletions

View File

@@ -3,6 +3,17 @@ use super::*;
extern crate test;
use test::{black_box, Bencher};
impl<T> TinyList<T> {
fn len(&self) -> usize {
let (mut elem, mut count) = (self.head.as_ref(), 0);
while let Some(ref e) = elem {
count += 1;
elem = e.next.as_deref();
}
count
}
}
#[test]
fn test_contains_and_insert() {
fn do_insert(i: u32) -> bool {