Skip to content

Commit

Permalink
added to_smallvec extension trait to slice primitive
Browse files Browse the repository at this point in the history
  • Loading branch information
UnicodingUnicorn committed Feb 21, 2020
1 parent 08b8249 commit 511194c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib.rs
Expand Up @@ -1684,6 +1684,17 @@ impl_array!(
0x40000, 0x60000, 0x80000, 0x10_0000
);

trait ToSmallVec<A:Array> {
fn to_smallvec(&self) -> SmallVec<A>;
}

impl<A:Array> ToSmallVec<A> for [A::Item]
where A::Item: Copy {
fn to_smallvec(&self) -> SmallVec<A> {
SmallVec::from_slice(self)
}
}

#[cfg(test)]
mod tests {
use crate::SmallVec;
Expand Down

0 comments on commit 511194c

Please sign in to comment.