This question refers to the stable Rust version 1.2.0
I just want to iterate over the characters in the standard input of my CLI application. It's perfectly possible to do read stdin
's read_line method into a temporary String
instance and then iterate over it's chars()
iterator.
But I don't like this approach, as it allocates a totally unnecessary String
object. Stdin
trait's documentations implements Read
trait, which has chars()
iterator, but it is marked as unstable (and thus can't be used with a stable compiler version).
Is there an alternative, possible less obvious way to read stdin char-by-char without any additional Rust-side buffering?