use std::convert::TryInto;
// *** 以前 ***
// 收窄的 as 转换会悄悄截断数字
let big: i64 = 300;
let small = big as u8; // 44,没有任何迹象表明出了问题
// *** 在 1.34 版本中 ***
// 可能失败的转换返回 Result
let big: i64 = 300;
match big.try_into() {
Ok(small) => println!("it fits: {}", small as u8),
Err(_) => println!("does not fit into u8"),
}