|
|
|
@ -4,6 +4,7 @@ use std::{
|
|
|
|
|
fmt,
|
|
|
|
|
ops,
|
|
|
|
|
};
|
|
|
|
|
use smallvec::SmallVec;
|
|
|
|
|
|
|
|
|
|
/// Wrapper to derive debug for types that don't implement it.
|
|
|
|
|
#[repr(transparent)]
|
|
|
|
@ -83,6 +84,15 @@ impl<T> BackInserter<T> for Vec<T>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<T> BackInserter<T> for SmallVec<T>
|
|
|
|
|
where T: smallvec::Array<Item = T>
|
|
|
|
|
{
|
|
|
|
|
#[inline] fn push_back(&mut self, value: T)
|
|
|
|
|
{
|
|
|
|
|
self.push(value)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Absracts a closure for `BackInserter<T>`.
|
|
|
|
|
pub struct BackInsertPass<T,F>(F, PhantomData<T>)
|
|
|
|
|
where F: FnMut(T);
|
|
|
|
@ -140,6 +150,14 @@ where T: BackInserter<T>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<T> BackInserter<T> for Option<T>
|
|
|
|
|
{
|
|
|
|
|
fn push_back(&mut self, value: T)
|
|
|
|
|
{
|
|
|
|
|
*self = Some(value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub trait VecExt<T>
|
|
|
|
|
{
|
|
|
|
|
/// Insert many elements with exact size iterator
|
|
|
|
@ -290,7 +308,7 @@ mod tests
|
|
|
|
|
assert_eq!(&vec[..], &vec2[..]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[cfg(nightly)]
|
|
|
|
|
#[cfg(feature="nightly")]
|
|
|
|
|
mod benchmatks
|
|
|
|
|
{
|
|
|
|
|
use super::super::*;
|
|
|
|
|