Skip to content

Commit 064b44f

Browse files
apply cr
1 parent a1aa3f8 commit 064b44f

File tree

4 files changed

+112
-113
lines changed

4 files changed

+112
-113
lines changed

src/io/read/bytes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::io::{self, Read};
44
use crate::stream::stream::Stream;
55
use crate::task::{Context, Poll};
66

7-
/// An iterator over `u8` values of a reader.
7+
/// A stream over `u8` values of a reader.
88
///
99
/// This struct is generally created by calling [`bytes`] on a reader.
1010
/// Please see the documentation of [`bytes`] for more details.

src/io/read/chain.rs

+24-24
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@ impl<T, U> Chain<T, U> {
2323
/// # Examples
2424
///
2525
/// ```no_run
26-
/// use async_std::io;
26+
/// # fn main() -> async_std::io::Result<()> { async_std::task::block_on(async {
27+
/// #
2728
/// use async_std::prelude::*;
2829
/// use async_std::fs::File;
2930
///
30-
/// fn main() -> io::Result<()> { async_std::task::block_on(async {
31-
/// let foo_file = File::open("foo.txt").await?;
32-
/// let bar_file = File::open("bar.txt").await?;
31+
/// let foo_file = File::open("foo.txt").await?;
32+
/// let bar_file = File::open("bar.txt").await?;
3333
///
34-
/// let chain = foo_file.chain(bar_file);
35-
/// let (foo_file, bar_file) = chain.into_inner();
36-
/// Ok(())
37-
/// }) }
34+
/// let chain = foo_file.chain(bar_file);
35+
/// let (foo_file, bar_file) = chain.into_inner();
36+
/// #
37+
/// # Ok(()) }) }
3838
/// ```
3939
pub fn into_inner(self) -> (T, U) {
4040
(self.first, self.second)
@@ -45,18 +45,18 @@ impl<T, U> Chain<T, U> {
4545
/// # Examples
4646
///
4747
/// ```no_run
48-
/// use async_std::io;
48+
/// # fn main() -> async_std::io::Result<()> { async_std::task::block_on(async {
49+
/// #
4950
/// use async_std::prelude::*;
5051
/// use async_std::fs::File;
5152
///
52-
/// fn main() -> io::Result<()> { async_std::task::block_on(async {
53-
/// let foo_file = File::open("foo.txt").await?;
54-
/// let bar_file = File::open("bar.txt").await?;
53+
/// let foo_file = File::open("foo.txt").await?;
54+
/// let bar_file = File::open("bar.txt").await?;
5555
///
56-
/// let chain = foo_file.chain(bar_file);
57-
/// let (foo_file, bar_file) = chain.get_ref();
58-
/// Ok(())
59-
/// }) }
56+
/// let chain = foo_file.chain(bar_file);
57+
/// let (foo_file, bar_file) = chain.get_ref();
58+
/// #
59+
/// # Ok(()) }) }
6060
/// ```
6161
pub fn get_ref(&self) -> (&T, &U) {
6262
(&self.first, &self.second)
@@ -71,18 +71,18 @@ impl<T, U> Chain<T, U> {
7171
/// # Examples
7272
///
7373
/// ```no_run
74-
/// use async_std::io;
74+
/// # fn main() -> async_std::io::Result<()> { async_std::task::block_on(async {
75+
/// #
7576
/// use async_std::prelude::*;
7677
/// use async_std::fs::File;
7778
///
78-
/// fn main() -> io::Result<()> { async_std::task::block_on(async {
79-
/// let foo_file = File::open("foo.txt").await?;
80-
/// let bar_file = File::open("bar.txt").await?;
79+
/// let foo_file = File::open("foo.txt").await?;
80+
/// let bar_file = File::open("bar.txt").await?;
8181
///
82-
/// let mut chain = foo_file.chain(bar_file);
83-
/// let (foo_file, bar_file) = chain.get_mut();
84-
/// Ok(())
85-
/// }) }
82+
/// let mut chain = foo_file.chain(bar_file);
83+
/// let (foo_file, bar_file) = chain.get_mut();
84+
/// #
85+
/// # Ok(()) }) }
8686
/// ```
8787
pub fn get_mut(&mut self) -> (&mut T, &mut U) {
8888
(&mut self.first, &mut self.second)

src/io/read/mod.rs

+43-44
Original file line numberDiff line numberDiff line change
@@ -282,21 +282,20 @@ extension_trait! {
282282
[`read()`]: tymethod.read
283283
284284
```no_run
285+
# fn main() -> std::io::Result<()> { async_std::task::block_on(async {
286+
#
285287
use async_std::io::prelude::*;
286288
use async_std::fs::File;
287289
288-
fn main() -> std::io::Result<()> {
289-
async_std::task::block_on(async {
290-
let f = File::open("foo.txt").await?;
291-
let mut buffer = [0; 5];
290+
let f = File::open("foo.txt").await?;
291+
let mut buffer = [0; 5];
292292
293-
// read at most five bytes
294-
let mut handle = f.take(5);
293+
// read at most five bytes
294+
let mut handle = f.take(5);
295295
296-
handle.read(&mut buffer).await?;
297-
Ok(())
298-
})
299-
}
296+
handle.read(&mut buffer).await?;
297+
#
298+
# Ok(()) }) }
300299
```
301300
"#]
302301
fn take(self, limit: u64) -> take::Take<Self>
@@ -319,27 +318,27 @@ extension_trait! {
319318
[file]: ../fs/struct.File.html
320319
321320
```no_run
322-
use async_std::io;
321+
# fn main() -> std::io::Result<()> { async_std::task::block_on(async {
322+
#
323323
use async_std::prelude::*;
324324
use async_std::fs::File;
325325
326-
fn main() -> io::Result<()> { async_std::task::block_on(async {
327-
let mut f = File::open("foo.txt").await?;
328-
let mut buffer = Vec::new();
329-
let mut other_buffer = Vec::new();
326+
let mut f = File::open("foo.txt").await?;
327+
let mut buffer = Vec::new();
328+
let mut other_buffer = Vec::new();
330329
331-
{
332-
let reference = f.by_ref();
330+
{
331+
let reference = f.by_ref();
333332
334-
// read at most 5 bytes
335-
reference.take(5).read_to_end(&mut buffer).await?;
333+
// read at most 5 bytes
334+
reference.take(5).read_to_end(&mut buffer).await?;
336335
337-
} // drop our &mut reference so we can use f again
336+
} // drop our &mut reference so we can use f again
338337
339-
// original file still usable, read the rest
340-
f.read_to_end(&mut other_buffer).await?;
341-
Ok(())
342-
}) }
338+
// original file still usable, read the rest
339+
f.read_to_end(&mut other_buffer).await?;
340+
#
341+
# Ok(()) }) }
343342
```
344343
"#]
345344
fn by_ref(&mut self) -> &mut Self where Self: Sized { self }
@@ -360,19 +359,19 @@ extension_trait! {
360359
[file]: ../fs/struct.File.html
361360
362361
```no_run
363-
use async_std::io;
362+
# fn main() -> std::io::Result<()> { async_std::task::block_on(async {
363+
#
364364
use async_std::prelude::*;
365365
use async_std::fs::File;
366366
367-
fn main() -> io::Result<()> { async_std::task::block_on(async {
368-
let f = File::open("foo.txt").await?;
369-
let mut s = f.bytes();
367+
let f = File::open("foo.txt").await?;
368+
let mut s = f.bytes();
370369
371-
while let Some(byte) = s.next().await {
372-
println!("{}", byte.unwrap());
373-
}
374-
Ok(())
375-
}) }
370+
while let Some(byte) = s.next().await {
371+
println!("{}", byte.unwrap());
372+
}
373+
#
374+
# Ok(()) }) }
376375
```
377376
"#]
378377
fn bytes(self) -> bytes::Bytes<Self> where Self: Sized {
@@ -393,22 +392,22 @@ extension_trait! {
393392
[file]: ../fs/struct.File.html
394393
395394
```no_run
396-
use async_std::io;
395+
# fn main() -> std::io::Result<()> { async_std::task::block_on(async {
396+
#
397397
use async_std::prelude::*;
398398
use async_std::fs::File;
399399
400-
fn main() -> io::Result<()> { async_std::task::block_on(async {
401-
let f1 = File::open("foo.txt").await?;
402-
let f2 = File::open("bar.txt").await?;
400+
let f1 = File::open("foo.txt").await?;
401+
let f2 = File::open("bar.txt").await?;
403402
404-
let mut handle = f1.chain(f2);
405-
let mut buffer = String::new();
403+
let mut handle = f1.chain(f2);
404+
let mut buffer = String::new();
406405
407-
// read the value into a String. We could use any Read method here,
408-
// this is just one example.
409-
handle.read_to_string(&mut buffer).await?;
410-
Ok(())
411-
}) }
406+
// read the value into a String. We could use any Read method here,
407+
// this is just one example.
408+
handle.read_to_string(&mut buffer).await?;
409+
#
410+
# Ok(()) }) }
412411
```
413412
"#]
414413
fn chain<R: Read>(self, next: R) -> chain::Chain<Self, R> where Self: Sized {

src/io/read/take.rs

+44-44
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ impl<T> Take<T> {
3030
/// # Examples
3131
///
3232
/// ```no_run
33-
/// use async_std::io;
33+
/// # fn main() -> async_std::io::Result<()> { async_std::task::block_on(async {
34+
/// #
3435
/// use async_std::prelude::*;
3536
/// use async_std::fs::File;
3637
///
37-
/// fn main() -> io::Result<()> { async_std::task::block_on(async {
38-
/// let f = File::open("foo.txt").await?;
38+
/// let f = File::open("foo.txt").await?;
3939
///
40-
/// // read at most five bytes
41-
/// let handle = f.take(5);
40+
/// // read at most five bytes
41+
/// let handle = f.take(5);
4242
///
43-
/// println!("limit: {}", handle.limit());
44-
/// Ok(())
45-
/// }) }
43+
/// println!("limit: {}", handle.limit());
44+
/// #
45+
/// # Ok(()) }) }
4646
/// ```
4747
pub fn limit(&self) -> u64 {
4848
self.limit
@@ -56,20 +56,20 @@ impl<T> Take<T> {
5656
/// # Examples
5757
///
5858
/// ```no_run
59-
/// use async_std::io;
59+
/// # fn main() -> async_std::io::Result<()> { async_std::task::block_on(async {
60+
/// #
6061
/// use async_std::prelude::*;
6162
/// use async_std::fs::File;
6263
///
63-
/// fn main() -> io::Result<()> { async_std::task::block_on(async {
64-
/// let f = File::open("foo.txt").await?;
64+
/// let f = File::open("foo.txt").await?;
6565
///
66-
/// // read at most five bytes
67-
/// let mut handle = f.take(5);
68-
/// handle.set_limit(10);
66+
/// // read at most five bytes
67+
/// let mut handle = f.take(5);
68+
/// handle.set_limit(10);
6969
///
70-
/// assert_eq!(handle.limit(), 10);
71-
/// Ok(())
72-
/// }) }
70+
/// assert_eq!(handle.limit(), 10);
71+
/// #
72+
/// # Ok(()) }) }
7373
/// ```
7474
pub fn set_limit(&mut self, limit: u64) {
7575
self.limit = limit;
@@ -80,20 +80,20 @@ impl<T> Take<T> {
8080
/// # Examples
8181
///
8282
/// ```no_run
83-
/// use async_std::io;
83+
/// # fn main() -> async_std::io::Result<()> { async_std::task::block_on(async {
84+
/// #
8485
/// use async_std::prelude::*;
8586
/// use async_std::fs::File;
8687
///
87-
/// fn main() -> io::Result<()> { async_std::task::block_on(async {
88-
/// let file = File::open("foo.txt").await?;
88+
/// let file = File::open("foo.txt").await?;
8989
///
90-
/// let mut buffer = [0; 5];
91-
/// let mut handle = file.take(5);
92-
/// handle.read(&mut buffer).await?;
90+
/// let mut buffer = [0; 5];
91+
/// let mut handle = file.take(5);
92+
/// handle.read(&mut buffer).await?;
9393
///
94-
/// let file = handle.into_inner();
95-
/// Ok(())
96-
/// }) }
94+
/// let file = handle.into_inner();
95+
/// #
96+
/// # Ok(()) }) }
9797
/// ```
9898
pub fn into_inner(self) -> T {
9999
self.inner
@@ -104,20 +104,20 @@ impl<T> Take<T> {
104104
/// # Examples
105105
///
106106
/// ```no_run
107-
/// use async_std::io;
107+
/// # fn main() -> async_std::io::Result<()> { async_std::task::block_on(async {
108+
/// #
108109
/// use async_std::prelude::*;
109110
/// use async_std::fs::File;
110111
///
111-
/// fn main() -> io::Result<()> { async_std::task::block_on(async {
112-
/// let file = File::open("foo.txt").await?;
112+
/// let file = File::open("foo.txt").await?;
113113
///
114-
/// let mut buffer = [0; 5];
115-
/// let mut handle = file.take(5);
116-
/// handle.read(&mut buffer).await?;
114+
/// let mut buffer = [0; 5];
115+
/// let mut handle = file.take(5);
116+
/// handle.read(&mut buffer).await?;
117117
///
118-
/// let file = handle.get_ref();
119-
/// Ok(())
120-
/// }) }
118+
/// let file = handle.get_ref();
119+
/// #
120+
/// # Ok(()) }) }
121121
/// ```
122122
pub fn get_ref(&self) -> &T {
123123
&self.inner
@@ -132,20 +132,20 @@ impl<T> Take<T> {
132132
/// # Examples
133133
///
134134
/// ```no_run
135-
/// use async_std::io;
135+
/// # fn main() -> async_std::io::Result<()> { async_std::task::block_on(async {
136+
/// #
136137
/// use async_std::prelude::*;
137138
/// use async_std::fs::File;
138139
///
139-
/// fn main() -> io::Result<()> { async_std::task::block_on(async {
140-
/// let file = File::open("foo.txt").await?;
140+
/// let file = File::open("foo.txt").await?;
141141
///
142-
/// let mut buffer = [0; 5];
143-
/// let mut handle = file.take(5);
144-
/// handle.read(&mut buffer).await?;
142+
/// let mut buffer = [0; 5];
143+
/// let mut handle = file.take(5);
144+
/// handle.read(&mut buffer).await?;
145145
///
146-
/// let file = handle.get_mut();
147-
/// Ok(())
148-
/// }) }
146+
/// let file = handle.get_mut();
147+
/// #
148+
/// # Ok(()) }) }
149149
/// ```
150150
pub fn get_mut(&mut self) -> &mut T {
151151
&mut self.inner

0 commit comments

Comments
 (0)