Egyúttal itt jegyzem meg, hogy a forráskódból az unsafe blokk warning-olható vagy tiltható a forráskód elejére tett opcióval. Így meg sem kell nézni a hátralevő részét, hogy van-e benne.
#![warn(unsafe_code)]
//#![forbid(unsafe_code)]
fn main() {
let x = [10, 20, 30];
println!("Csak teszt: {}", x[0]);
unsafe {
println!("Csak unsafe teszt: {}", x.get_unchecked(0));
}
}
$ rustc pelda.rs