Skip to content

Commit 511194c

Browse files
added to_smallvec extension trait to slice primitive
1 parent 08b8249 commit 511194c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,6 +1684,17 @@ impl_array!(
16841684
0x40000, 0x60000, 0x80000, 0x10_0000
16851685
);
16861686

1687+
trait ToSmallVec<A:Array> {
1688+
fn to_smallvec(&self) -> SmallVec<A>;
1689+
}
1690+
1691+
impl<A:Array> ToSmallVec<A> for [A::Item]
1692+
where A::Item: Copy {
1693+
fn to_smallvec(&self) -> SmallVec<A> {
1694+
SmallVec::from_slice(self)
1695+
}
1696+
}
1697+
16871698
#[cfg(test)]
16881699
mod tests {
16891700
use crate::SmallVec;

0 commit comments

Comments
 (0)