Rollup merge of #88601 - ibraheemdev:termination-result-infallible, r=yaahc

Implement `Termination` for `Result<Infallible, E>`

As noted in #43301, `Result<!, E>` is not usable on stable.
This commit is contained in:
Yuki Okushi 2021-11-16 09:14:15 +09:00 committed by GitHub
commit c44455af1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -106,6 +106,7 @@ mod tests;
use crate::io::prelude::*;
use crate::convert::Infallible;
use crate::ffi::OsStr;
use crate::fmt;
use crate::fs;
@ -2065,6 +2066,14 @@ impl<E: fmt::Debug> Termination for Result<!, E> {
}
}
#[unstable(feature = "termination_trait_lib", issue = "43301")]
impl<E: fmt::Debug> Termination for Result<Infallible, E> {
fn report(self) -> i32 {
let Err(err) = self;
Err::<!, _>(err).report()
}
}
#[unstable(feature = "termination_trait_lib", issue = "43301")]
impl Termination for ExitCode {
#[inline]