Skip to content

Commit fbf52d3

Browse files
committed
prefer to use integer cast API
1 parent bab64fd commit fbf52d3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/g3-types/src/codec/thrift/var_int.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl ThriftVarInt32 {
2020
// Get the varint value used directly in thrift protocol,
2121
// which is always positive and not zigzag encoded
2222
pub fn positive_value(&self) -> i32 {
23-
self.leb128.value() as i32
23+
u32::cast_signed(self.leb128.value())
2424
}
2525

2626
// Get the thrift integer value, which is zigzag encoded
@@ -48,6 +48,6 @@ impl ThriftVarIntEncoder {
4848

4949
// Encode the positive varint used directly in thrift protocol, which will not be zigzag encoded
5050
pub fn encode_positive_i32(&mut self, v: i32) -> &[u8] {
51-
self.leb128.encode_u32(v as u32)
51+
self.leb128.encode_u32(i32::cast_unsigned(v))
5252
}
5353
}

0 commit comments

Comments
 (0)