[][src]Function rustils::parse::ubyte::i16_to_u8_res

pub fn i16_to_u8_res(a: i16) -> ParseResultU8

Parse i16 to u8

Arguments

  • a - Any i16 number

Examples

use rustils::parse::ubyte::i16_to_u8_res;
use rustils::error::ParseError::InvalidNumber;

assert_eq!(i16_to_u8_res(0_i16), Ok(0_u8));
assert_eq!(i16_to_u8_res(255_i16), Ok(255_u8));
assert_eq!(i16_to_u8_res(-1_i16), Err(InvalidNumber(String::from("-1"))));
assert_eq!(i16_to_u8_res(256_i16), Err(InvalidNumber(String::from("256"))));