Skip to content

Commit 2bdd075

Browse files
committed
implement Termination for Result<Infallible, E>
1 parent 6cfa773 commit 2bdd075

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

library/std/src/process.rs

+10
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ mod tests;
106106

107107
use crate::io::prelude::*;
108108

109+
use crate::convert::Infallible;
109110
use crate::ffi::OsStr;
110111
use crate::fmt;
111112
use crate::fs;
@@ -2051,6 +2052,15 @@ impl<E: fmt::Debug> Termination for Result<!, E> {
20512052
}
20522053
}
20532054

2055+
#[unstable(feature = "termination_trait_lib", issue = "43301")]
2056+
impl<E: fmt::Debug> Termination for Result<Infallible, E> {
2057+
fn report(self) -> i32 {
2058+
let Err(err) = self;
2059+
eprintln!("Error: {:?}", err);
2060+
ExitCode::FAILURE.report()
2061+
}
2062+
}
2063+
20542064
#[unstable(feature = "termination_trait_lib", issue = "43301")]
20552065
impl Termination for ExitCode {
20562066
#[inline]

0 commit comments

Comments
 (0)