• D
    Rollup merge of #83353 - m-ou-se:io-error-avoid-alloc, r=nagisa · a42e62fa
    Dylan DPC 提交于
    Add internal io::Error::new_const to avoid allocations.
    
    This makes it possible to have a io::Error containing a message with zero allocations, and uses that everywhere to avoid the *three* allocations involved in `io::Error::new(kind, "message")`.
    
    The function signature isn't perfect, because it needs a reference to the `&str`. So for now, this is just a `pub(crate)` function. Later, we'll be able to use `fn new_const<MSG: &'static str>(kind: ErrorKind)` to make that a bit better. (Then we'll also be able to use some ZST trickery if that would result in more efficient code.)
    
    See https://github.com/rust-lang/rust/issues/83352
    a42e62fa
process_unix.rs 20.1 KB