1
Fork 0

Make raw standard stream constructors const

This commit is contained in:
Tomasz Miąsko 2020-08-20 00:00:00 +00:00
parent 479c23bb49
commit 4a00421ba4
10 changed files with 33 additions and 30 deletions

View file

@ -50,7 +50,8 @@ struct StderrRaw(stdio::Stderr);
/// handles is **not** available to raw handles returned from this function. /// handles is **not** available to raw handles returned from this function.
/// ///
/// The returned handle has no external synchronization or buffering. /// The returned handle has no external synchronization or buffering.
fn stdin_raw() -> StdinRaw { #[unstable(feature = "libstd_sys_internals", issue = "none")]
const fn stdin_raw() -> StdinRaw {
StdinRaw(stdio::Stdin::new()) StdinRaw(stdio::Stdin::new())
} }
@ -63,7 +64,8 @@ fn stdin_raw() -> StdinRaw {
/// ///
/// The returned handle has no external synchronization or buffering layered on /// The returned handle has no external synchronization or buffering layered on
/// top. /// top.
fn stdout_raw() -> StdoutRaw { #[unstable(feature = "libstd_sys_internals", issue = "none")]
const fn stdout_raw() -> StdoutRaw {
StdoutRaw(stdio::Stdout::new()) StdoutRaw(stdio::Stdout::new())
} }
@ -74,7 +76,8 @@ fn stdout_raw() -> StdoutRaw {
/// ///
/// The returned handle has no external synchronization or buffering layered on /// The returned handle has no external synchronization or buffering layered on
/// top. /// top.
fn stderr_raw() -> StderrRaw { #[unstable(feature = "libstd_sys_internals", issue = "none")]
const fn stderr_raw() -> StderrRaw {
StderrRaw(stdio::Stderr::new()) StderrRaw(stdio::Stderr::new())
} }

View file

@ -6,7 +6,7 @@ pub struct Stdout(());
pub struct Stderr(()); pub struct Stderr(());
impl Stdin { impl Stdin {
pub fn new() -> Stdin { pub const fn new() -> Stdin {
Stdin(()) Stdin(())
} }
} }
@ -18,7 +18,7 @@ impl io::Read for Stdin {
} }
impl Stdout { impl Stdout {
pub fn new() -> Stdout { pub const fn new() -> Stdout {
Stdout(()) Stdout(())
} }
} }
@ -37,7 +37,7 @@ impl io::Write for Stdout {
} }
impl Stderr { impl Stderr {
pub fn new() -> Stderr { pub const fn new() -> Stderr {
Stderr(()) Stderr(())
} }
} }

View file

@ -7,7 +7,7 @@ pub struct Stdout;
pub struct Stderr; pub struct Stderr;
impl Stdin { impl Stdin {
pub fn new() -> Stdin { pub const fn new() -> Stdin {
Stdin Stdin
} }
} }
@ -28,7 +28,7 @@ impl io::Read for Stdin {
} }
impl Stdout { impl Stdout {
pub fn new() -> Stdout { pub const fn new() -> Stdout {
Stdout Stdout
} }
} }
@ -69,7 +69,7 @@ impl io::Write for Stdout {
} }
impl Stderr { impl Stderr {
pub fn new() -> Stderr { pub const fn new() -> Stderr {
Stderr Stderr
} }
} }

View file

@ -19,7 +19,7 @@ fn with_std_fd<F: FnOnce(&FileDesc) -> R, R>(fd: abi::Fd, f: F) -> R {
} }
impl Stdin { impl Stdin {
pub fn new() -> Stdin { pub const fn new() -> Stdin {
Stdin(()) Stdin(())
} }
} }
@ -31,7 +31,7 @@ impl io::Read for Stdin {
} }
impl Stdout { impl Stdout {
pub fn new() -> Stdout { pub const fn new() -> Stdout {
Stdout(()) Stdout(())
} }
} }
@ -47,7 +47,7 @@ impl io::Write for Stdout {
} }
impl Stderr { impl Stderr {
pub fn new() -> Stderr { pub const fn new() -> Stderr {
Stderr(()) Stderr(())
} }
} }

View file

@ -7,7 +7,7 @@ pub struct Stdout(());
pub struct Stderr(()); pub struct Stderr(());
impl Stdin { impl Stdin {
pub fn new() -> Stdin { pub const fn new() -> Stdin {
Stdin(()) Stdin(())
} }
} }
@ -28,7 +28,7 @@ impl io::Read for Stdin {
} }
impl Stdout { impl Stdout {
pub fn new() -> Stdout { pub const fn new() -> Stdout {
Stdout(()) Stdout(())
} }
} }
@ -53,7 +53,7 @@ impl io::Write for Stdout {
} }
impl Stderr { impl Stderr {
pub fn new() -> Stderr { pub const fn new() -> Stderr {
Stderr(()) Stderr(())
} }
} }

View file

@ -5,7 +5,7 @@ pub struct Stdout;
pub struct Stderr; pub struct Stderr;
impl Stdin { impl Stdin {
pub fn new() -> Stdin { pub const fn new() -> Stdin {
Stdin Stdin
} }
} }
@ -17,7 +17,7 @@ impl io::Read for Stdin {
} }
impl Stdout { impl Stdout {
pub fn new() -> Stdout { pub const fn new() -> Stdout {
Stdout Stdout
} }
} }
@ -33,7 +33,7 @@ impl io::Write for Stdout {
} }
impl Stderr { impl Stderr {
pub fn new() -> Stderr { pub const fn new() -> Stderr {
Stderr Stderr
} }
} }

View file

@ -6,7 +6,7 @@ pub struct Stdout(());
pub struct Stderr(()); pub struct Stderr(());
impl Stdin { impl Stdin {
pub fn new() -> Stdin { pub const fn new() -> Stdin {
Stdin(()) Stdin(())
} }
} }
@ -21,7 +21,7 @@ impl io::Read for Stdin {
} }
impl Stdout { impl Stdout {
pub fn new() -> Stdout { pub const fn new() -> Stdout {
Stdout(()) Stdout(())
} }
} }
@ -40,7 +40,7 @@ impl io::Write for Stdout {
} }
impl Stderr { impl Stderr {
pub fn new() -> Stderr { pub const fn new() -> Stderr {
Stderr(()) Stderr(())
} }
} }

View file

@ -7,7 +7,7 @@ pub struct Stdout;
pub struct Stderr; pub struct Stderr;
impl Stdin { impl Stdin {
pub fn new() -> Stdin { pub const fn new() -> Stdin {
Stdin Stdin
} }
@ -33,7 +33,7 @@ impl io::Read for Stdin {
} }
impl Stdout { impl Stdout {
pub fn new() -> Stdout { pub const fn new() -> Stdout {
Stdout Stdout
} }
@ -62,7 +62,7 @@ impl io::Write for Stdout {
} }
impl Stderr { impl Stderr {
pub fn new() -> Stderr { pub const fn new() -> Stderr {
Stderr Stderr
} }

View file

@ -131,7 +131,7 @@ fn write_u16s(handle: c::HANDLE, data: &[u16]) -> io::Result<usize> {
} }
impl Stdin { impl Stdin {
pub fn new() -> Stdin { pub const fn new() -> Stdin {
Stdin { surrogate: 0 } Stdin { surrogate: 0 }
} }
} }
@ -255,7 +255,7 @@ fn utf16_to_utf8(utf16: &[u16], utf8: &mut [u8]) -> io::Result<usize> {
} }
impl Stdout { impl Stdout {
pub fn new() -> Stdout { pub const fn new() -> Stdout {
Stdout Stdout
} }
} }
@ -271,7 +271,7 @@ impl io::Write for Stdout {
} }
impl Stderr { impl Stderr {
pub fn new() -> Stderr { pub const fn new() -> Stderr {
Stderr Stderr
} }
} }

View file

@ -30,7 +30,7 @@ fn write(handle_id: c::DWORD, data: &[u8]) -> io::Result<usize> {
} }
impl Stdin { impl Stdin {
pub fn new() -> Stdin { pub const fn new() -> Stdin {
Stdin {} Stdin {}
} }
} }
@ -44,7 +44,7 @@ impl io::Read for Stdin {
} }
impl Stdout { impl Stdout {
pub fn new() -> Stdout { pub const fn new() -> Stdout {
Stdout Stdout
} }
} }
@ -60,7 +60,7 @@ impl io::Write for Stdout {
} }
impl Stderr { impl Stderr {
pub fn new() -> Stderr { pub const fn new() -> Stderr {
Stderr Stderr
} }
} }