On this page
Function std::io::empty
pub fn empty() -> Empty ⓘ
Creates a value that is always at EOF for reads, and ignores all data written.
All calls to write
on the returned instance will return Ok(buf.len())
and the contents of the buffer will not be inspected.
All calls to read
from the returned reader will return Ok(0)
.
Examples
use std::io::{self, Write};
let buffer = vec![1, 2, 3, 5, 8];
let num_bytes = io::empty().write(&buffer).unwrap();
assert_eq!(num_bytes, 5);
use std::io::{self, Read};
let mut buffer = String::new();
io::empty().read_to_string(&mut buffer).unwrap();
assert!(buffer.is_empty());
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/io/fn.empty.html