[−][src]Crate io_enum
#[derive(Read, BufRead, Write, Seek)] for enums.
Examples
use io_enum::*; use std::fs::File; use std::io::{self, Write}; use std::path::Path; #[derive(Read, BufRead, Write, Seek)] enum Either<A, B> { A(A), B(B), } fn foo(path: Option<&Path>) -> impl Write { if let Some(path) = path { Either::A(File::open(path).unwrap()) } else { Either::B(io::stdout()) } }
See auto_enums for how to automate patterns like this.
Supported traits
See auto_enums#11 for other traits.
Crate Features
read_initializer
- Disabled by default.
- Implements
io::Read::read_initializer
. - This requires Rust Nightly and you need to enable the unstable
read_initializer
feature gate.
Derive Macros
BufRead | |
Read | |
Seek | |
Write |