forked from mirror/async-std
refactor io dir to be same with std
This commit is contained in:
parent
f611ceccc8
commit
9d634cb2a7
3 changed files with 6 additions and 8 deletions
|
@ -4,11 +4,9 @@ use std::{cmp, fmt};
|
|||
|
||||
use pin_project_lite::pin_project;
|
||||
|
||||
use crate::io::{self, BufRead, Read, Seek, SeekFrom};
|
||||
use crate::io::{self, BufRead, Read, Seek, SeekFrom, DEFAULT_BUF_SIZE};
|
||||
use crate::task::{Context, Poll};
|
||||
|
||||
const DEFAULT_CAPACITY: usize = 8 * 1024;
|
||||
|
||||
pin_project! {
|
||||
/// Adds buffering to any reader.
|
||||
///
|
||||
|
@ -72,7 +70,7 @@ impl<R: io::Read> BufReader<R> {
|
|||
/// # Ok(()) }) }
|
||||
/// ```
|
||||
pub fn new(inner: R) -> BufReader<R> {
|
||||
BufReader::with_capacity(DEFAULT_CAPACITY, inner)
|
||||
BufReader::with_capacity(DEFAULT_BUF_SIZE, inner)
|
||||
}
|
||||
|
||||
/// Creates a new buffered reader with the specified capacity.
|
||||
|
|
|
@ -4,11 +4,9 @@ use std::pin::Pin;
|
|||
use pin_project_lite::pin_project;
|
||||
|
||||
use crate::io::write::WriteExt;
|
||||
use crate::io::{self, Seek, SeekFrom, Write};
|
||||
use crate::io::{self, Seek, SeekFrom, Write, DEFAULT_BUF_SIZE};
|
||||
use crate::task::{Context, Poll, ready};
|
||||
|
||||
const DEFAULT_CAPACITY: usize = 8 * 1024;
|
||||
|
||||
pin_project! {
|
||||
/// Wraps a writer and buffers its output.
|
||||
///
|
||||
|
@ -107,7 +105,7 @@ impl<W: Write> BufWriter<W> {
|
|||
/// # Ok(()) }) }
|
||||
/// ```
|
||||
pub fn new(inner: W) -> BufWriter<W> {
|
||||
BufWriter::with_capacity(DEFAULT_CAPACITY, inner)
|
||||
BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner)
|
||||
}
|
||||
|
||||
/// Creates a new `BufWriter` with the specified buffer capacity.
|
||||
|
|
|
@ -269,6 +269,8 @@
|
|||
//! [`Result`]: https://doc.rust-lang.org/std/result/enum.Result.html
|
||||
//! [`.unwrap()`]: https://doc.rust-lang.org/std/result/enum.Result.html#method.unwrap
|
||||
|
||||
const DEFAULT_BUF_SIZE: usize = 8 * 1024;
|
||||
|
||||
cfg_std! {
|
||||
#[doc(inline)]
|
||||
pub use std::io::{Error, ErrorKind, IoSlice, IoSliceMut, Result, SeekFrom};
|
||||
|
|
Loading…
Reference in a new issue