TryFrom and TryInto

Changes in new versions / Rust 1.34

use std::convert::TryInto;

// *** before: ***
// a narrowing as cast silently cut the number down
let big: i64 = 300;
let small = big as u8;      // 44, with nothing to say it went wrong

// *** in version 1.34: ***
// a conversion that may fail returns a Result
let big: i64 = 300;
match big.try_into() {
    Ok(small) => println!("it fits: {}", small as u8),
    Err(_) => println!("does not fit into u8"),
}