Skip to content

Commit 36e987b

Browse files
authored
Merge pull request #50 from mjbvz/fix-usize-x32
Fix incorrect use of usize for 32 bit systems
2 parents c01967b + 7293c57 commit 36e987b

File tree

1 file changed

+2
-2
lines changed
  • crates/string-offsets/src

1 file changed

+2
-2
lines changed

crates/string-offsets/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,8 @@ fn new_converter(content: &[u8]) -> StringOffsets {
385385
/// Returns 0 if the byte is not a valid first byte of a UTF-8 char.
386386
fn utf8_width(c: u8) -> usize {
387387
// Every nibble represents the utf8 length given the first 4 bits of a utf8 encoded byte.
388-
const UTF8_WIDTH: usize = 0x4322_0000_1111_1111;
389-
(UTF8_WIDTH >> ((c >> 4) * 4)) & 0xf
388+
const UTF8_WIDTH: u64 = 0x4322_0000_1111_1111;
389+
((UTF8_WIDTH >> ((c >> 4) * 4)) & 0xf) as usize
390390
}
391391

392392
fn utf8_to_utf16_width(content: &[u8]) -> usize {

0 commit comments

Comments
 (0)