Skip to content

Commit 2b2cf26

Browse files
authored
Use const generics for IVec::from array
This will move the minimum supported rust version to 1.51, which may or may not be acceptable.
1 parent c840fe7 commit 2b2cf26

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

src/ivec.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -263,23 +263,12 @@ impl std::borrow::Borrow<[u8]> for &IVec {
263263
}
264264
}
265265

266-
macro_rules! from_array {
267-
($($s:expr),*) => {
268-
$(
269-
impl From<&[u8; $s]> for IVec {
270-
fn from(v: &[u8; $s]) -> Self {
271-
Self::from(&v[..])
272-
}
273-
}
274-
)*
266+
impl<const N: usize> From<&[u8; N]> for IVec {
267+
fn from(v: &[u8; N]) -> Self {
268+
Self::from(&v[..])
275269
}
276270
}
277271

278-
from_array!(
279-
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
280-
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32
281-
);
282-
283272
impl Ord for IVec {
284273
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
285274
self.as_ref().cmp(other.as_ref())

0 commit comments

Comments
 (0)