Skip to content

Commit b697ca5

Browse files
committed
Merge pull request SSheldon#11 from madsmtm/encoding-parameter-size
Change Encoding parameter sizes
2 parents 1d1ad54 + f13996e commit b697ca5

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

objc_encode/src/encode.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ unsafe impl Encode for *const c_void {
6464
}
6565

6666
unsafe impl<T: Encode, const LENGTH: usize> Encode for [T; LENGTH] {
67-
const ENCODING: Encoding<'static> = Encoding::Array(LENGTH as u32, &<T as Encode>::ENCODING);
67+
const ENCODING: Encoding<'static> = Encoding::Array(LENGTH, &<T as Encode>::ENCODING);
6868
}
6969

7070
// External crates cannot implement Encode for pointers or [`Option`], but

objc_encode/src/encoding.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ pub enum Encoding<'a> {
2828
Class,
2929
Sel,
3030
Unknown,
31-
BitField(u32),
31+
BitField(u8),
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
}

objc_encode/src/parse.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn rm_enc_prefix<'a>(s: &'a str, enc: &Encoding<'_>) -> Option<&'a str> {
3737
Unknown => "?",
3838
BitField(b) => {
3939
let s = s.strip_prefix('b')?;
40-
return rm_int_prefix(s, b);
40+
return rm_int_prefix(s, b as usize);
4141
}
4242
Pointer(t) => {
4343
let s = s.strip_prefix('^')?;
@@ -75,7 +75,7 @@ fn rm_enc_prefix<'a>(s: &'a str, enc: &Encoding<'_>) -> Option<&'a str> {
7575
s.strip_prefix(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).and_then(|(n, t)| if other == n { Some(t) } else { None })
8989
}
9090

0 commit comments

Comments
 (0)