Skip to content

Commit 2e51358

Browse files
committed
Support arrays with more than 2^32 - 1 elements
@encode can output an array size up to 2^61 - 1 elements.
1 parent 0f2c404 commit 2e51358

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/encoding.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub enum Encoding<'a> {
3030
Unknown,
3131
BitField(u32),
3232
Pointer(&'a Encoding<'a>),
33-
Array(u32, &'a Encoding<'a>),
33+
Array(usize, &'a Encoding<'a>),
3434
Struct(&'a str, &'a [Encoding<'a>]),
3535
Union(&'a str, &'a [Encoding<'a>]),
3636
}

src/parse.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ fn rm_enc_prefix<'a>(s: &'a str, enc: &Encoding) -> Option<&'a str> {
7575
rm_prefix(s, code)
7676
}
7777

78-
fn chomp_int(s: &str) -> Option<(u32, &str)> {
78+
fn chomp_int(s: &str) -> Option<(usize, &str)> {
7979
// Chomp until we hit a non-digit
8080
let (num, t) = match s.find(|c: char| !c.is_digit(10)) {
8181
Some(i) => s.split_at(i),
@@ -84,7 +84,7 @@ fn chomp_int(s: &str) -> Option<(u32, &str)> {
8484
num.parse().map(|n| (n, t)).ok()
8585
}
8686

87-
fn rm_int_prefix(s: &str, other: u32) -> Option<&str> {
87+
fn rm_int_prefix(s: &str, other: usize) -> Option<&str> {
8888
chomp_int(s)
8989
.and_then(|(n, t)| if other == n { Some(t) } else { None })
9090
}

0 commit comments

Comments
 (0)