const_error in std::io - Rust
Description: Creates a new I/O error from a known kind of error and a string literal.

## const_error

# Macro const_error

Source

    pub macro const_error($kind:expr, $message:expr $(,)?) {
        ...
    }

🔬This is a nightly-only experimental API. (`io_const_error` #133448)
Expand description

Creates a new I/O error from a known kind of error and a string literal.

Contrary to `Error::new`, this macro does not allocate and can be used in `const` contexts.

## §Example

    #![feature(io_const_error)]
    use std::io::{const_error, Error, ErrorKind};

    const FAIL: Error = const_error!(ErrorKind::Unsupported, "tried something that never works");

    fn not_here() -> Result<(), Error> {
        Err(FAIL)
    }