Skip to content

Commit b862177

Browse files
committed
Be 16-bit clean
1 parent 0f4acdb commit b862177

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/size.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,12 @@ impl TryFrom<usize> for TextSize {
9797

9898
impl From<TextSize> for usize {
9999
fn from(value: TextSize) -> Self {
100-
value.raw as usize
100+
assert_lossless_conversion();
101+
return value.raw as usize;
102+
103+
const fn assert_lossless_conversion() {
104+
[()][(std::mem::size_of::<usize>() < std::mem::size_of::<u32>()) as usize]
105+
}
101106
}
102107
}
103108

0 commit comments

Comments
 (0)