pub fn empty() -> Empty ⓘ
Expand description
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);
Runuse std::io::{self, Read};
let mut buffer = String::new();
io::empty().read_to_string(&mut buffer).unwrap();
assert!(buffer.is_empty());
Run