We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents f13d09a + f66bcc5 commit 23b0776Copy full SHA for 23b0776
src/liballoc/vec.rs
@@ -1801,6 +1801,21 @@ impl<T: Clone> SpecFromElem for T {
1801
}
1802
1803
1804
+impl SpecFromElem for i8 {
1805
+ #[inline]
1806
+ fn from_elem(elem: i8, n: usize) -> Vec<i8> {
1807
+ if elem == 0 {
1808
+ return Vec { buf: RawVec::with_capacity_zeroed(n), len: n };
1809
+ }
1810
+ unsafe {
1811
+ let mut v = Vec::with_capacity(n);
1812
+ ptr::write_bytes(v.as_mut_ptr(), elem as u8, n);
1813
+ v.set_len(n);
1814
+ v
1815
1816
1817
+}
1818
+
1819
impl SpecFromElem for u8 {
1820
#[inline]
1821
fn from_elem(elem: u8, n: usize) -> Vec<u8> {
@@ -1845,7 +1860,6 @@ macro_rules! impl_is_zero {
1845
1860
};
1846
1861
1847
1862
1848
-impl_is_zero!(i8, |x| x == 0);
1849
1863
impl_is_zero!(i16, |x| x == 0);
1850
1864
impl_is_zero!(i32, |x| x == 0);
1851
1865
impl_is_zero!(i64, |x| x == 0);
0 commit comments