jrhenderson1988 / snake-rs

MIT License
29 stars 1 forks source link

u16 cannot be converted to i16 #2

Closed Jedsek closed 2 years ago

Jedsek commented 3 years ago
 pub fn transform(&self, direction: Direction, times: u16) -> Self {
    let times = times as i16;
    /*....omitted....*/
}

u16 -> [0, 65535] i16 -> [-32768, 32767]

For example: If times is 60000_u16, times = times as i16 will get -5536_i16
u16 can be rewritten to i32 (And in another fn: transform_value)