-> T { let stdin = stdin(); let stdin = stdin.lock(); let token: String = stdin .bytes() .map(|c| c.expect("failed to read char") as char) .skip_while(|c| c.is_whitespace()) .take_while(|c| !c.is_whitespace()) .collect(); token.parse().ok().expect("failed to parse token") } https://qiita.com/tubo28/items/ e6076e9040da57368845#%E5%85%A5%E5%87%BA%E5%8A%9B