]> git.lizzy.rs Git - rust.git/commit
rollup merge of #19416: sfackler/global-stdin
authorCorey Richardson <corey@octayn.net>
Fri, 5 Dec 2014 18:06:52 +0000 (10:06 -0800)
committerCorey Richardson <corey@octayn.net>
Fri, 5 Dec 2014 18:06:52 +0000 (10:06 -0800)
commita6ce402401f0da3a48a5a183ae109a00024ba666
tree0bc4fa5f3fe2b82889e7ab754ef68358a4cc8008
parent26f2867c2e5439156f40f18c5a828a5a94c4352a
parente7c1f57d6c8781cfb3e746eac5f13f760fcde2b4
rollup merge of #19416: sfackler/global-stdin

io::stdin returns a new `BufferedReader` each time it's called, which
results in some very confusing behavior with disappearing output. It now
returns a `StdinReader`, which wraps a global singleton
`Arc<Mutex<BufferedReader<StdReader>>`. `Reader` is implemented directly
on `StdinReader`. However, `Buffer` is not, as the `fill_buf` method is
fundamentaly un-thread safe. A `lock` method is defined on `StdinReader`
which returns a smart pointer wrapping the underlying `BufferedReader`
while guaranteeing mutual exclusion.

Code that treats the return value of io::stdin as implementing `Buffer`
will break. Add a call to `lock`:

```rust
io::stdin().read_line();
// =>
io::stdin().lock().read_line();
```

Closes #14434

[breaking-change]