Skip to content

Commit f4aa953

Browse files
committed
Merge pull request #2 from alexcrichton/pr2
A few updates/typos
2 parents 97c8935 + feb04ff commit f4aa953

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

text/0517-io-os-reform.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -519,15 +519,24 @@ struct PartialResult<T, Err>(T, Err);
519519
type NonatomicResult<S, T, Err> = Result<S, PartialResult<T, Err>>;
520520

521521
// Ergonomically throw out the partial result
522-
impl<T, Err> FromError<PartialResult<T, Err> for Err { ... }
522+
impl<T, Err> FromError<PartialResult<T, Err>> for Err { ... }
523523
```
524524

525525
The `NonatomicResult` type (which could use a shorter name)
526526
encapsulates the common pattern of operations that may fail after
527527
having made some progress. The `PartialResult` type then returns the
528528
progress that was made along with the error, but with a `FromError`
529529
implementation that makes it trivial to throw out the partial result
530-
if desired.
530+
if desired. For example, the following would be expected to compile:
531+
532+
```rust
533+
fn write(buf: &[u8]) -> NonatomicResult<(), uint, Error> { /* ... */ }
534+
535+
fn write_bytes() -> Result<(), Error> {
536+
try!(write!(&[1, 2, 3, 4]));
537+
Ok(())
538+
}
539+
```
531540

532541
### `Reader`
533542
[Reader]: #reader
@@ -649,7 +658,7 @@ throughout IO, we can go on to explore the modules in detail.
649658
### `core::io`
650659
[core::io]: #coreio
651660

652-
The `io` module is split into a the parts that can live in `libcore`
661+
The `io` module is split into the parts that can live in `libcore`
653662
(most of it) and the parts that are added in the `std::io`
654663
facade. Being able to move components into `libcore` at all is made
655664
possible through the use of
@@ -696,7 +705,7 @@ impl<T: Writer> WriterExt for T {}
696705
pub struct IterReader<T> { ... }
697706
```
698707

699-
As with `std::iter`, these adapters are object unsafe an hence placed
708+
As with `std::iter`, these adapters are object unsafe and hence placed
700709
in an extension trait with a blanket `impl`.
701710

702711
Note that the same `ByRef` type is used for both `Reader` and `Writer`
@@ -731,7 +740,7 @@ readers and writers, as well as `copy`. These are updated as follows:
731740

732741
```rust
733742
// A reader that yields no bytes
734-
fn empty() -> Empty;
743+
fn empty() -> Empty; // in theory just returns `impl Reader`
735744

736745
// A reader that yields `byte` repeatedly (generalizes today's ZeroReader)
737746
fn repeat(byte: u8) -> Repeat;
@@ -778,7 +787,8 @@ pub trait BufferedReader: Reader {
778787
fn fill_buf(&mut self) -> Result<&[u8], Self::Err>;
779788
fn consume(&mut self, amt: uint);
780789

781-
// This should perhaps yield an iterator
790+
// This should perhaps move to an iterator like `lines` where the iterator
791+
// yields vectors read.
782792
fn read_until(&mut self, byte: u8) -> NonatomicResult<Vec<u8>, Vec<u8>, Self::Err> { ... }
783793
}
784794

0 commit comments

Comments
 (0)