Undefined Behavior

Published 458d ago

 ayebear

fn main() {
    let mut v = Vec::new();
    v.push('a');
    let mut i = 0;
    loop {
        let a = unsafe { v.get_unchecked(i) };
        if *a != '\0' {
            println!("{}", a);
        }
        i += 1;
    }
}

3

Please login or sign up to comment and collaborate