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:
parent
5c6d3bf389
commit
620ecc01a2
8 changed files with 85 additions and 78 deletions
|
@ -15,7 +15,7 @@
|
|||
mod tests;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct TinyList<T: PartialEq> {
|
||||
pub struct TinyList<T> {
|
||||
head: Option<Element<T>>,
|
||||
}
|
||||
|
||||
|
@ -56,20 +56,10 @@ impl<T: PartialEq> TinyList<T> {
|
|||
}
|
||||
false
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub 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
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct Element<T: PartialEq> {
|
||||
struct Element<T> {
|
||||
data: T,
|
||||
next: Option<Box<Element<T>>>,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue