I'm not really certain what Rust commands do as I can't read manuals here, but this code passed the judge:
use std::io;
fn main(){
let mut stdin = io::stdin();
let mut line = String::new();
while true {
let n = stdin.read_line(&mut line);
let x = line.trim().parse::<i32>().unwrap();
if x == 42 {break;}
line.clear();
println!("{}",x);
}
}