std-type
ErrorKind: classify I/O failures
Classify failures using stable variants rather than platform-specific strings. The enum can gain variants; use a fallback for unknown kinds. Interrupted may be retried, while UnexpectedEof and WriteZero call for different handling. Expected stdout (not executed): truncated Common mistake: Retrying every kind indefinitely.
Formal Syntax & Structure
rust syntaxrust
match err.kind() { ErrorKind::Interrupted => ..., _ => ... }Working Example
Example Snippetrust
fn main() { use std::io::{Error, ErrorKind}; let e = Error::from(ErrorKind::UnexpectedEof); let label = match e.kind() { ErrorKind::UnexpectedEof => "truncated", ErrorKind::Interrupted => "retry", _ => "other", }; println!("{label}");}