agner_actors/exit/
into_exit.rs1use futures::never::Never;
2
3use crate::exit::Exit;
4
5impl From<()> for Exit {
6 fn from((): ()) -> Self {
7 Self::normal()
8 }
9}
10
11impl From<Never> for Exit {
12 fn from(infallible: Never) -> Self {
13 unreachable!(
14 "Whoa! We have an actual value of type `Infallible/Never`. Can I print it? Look — {:?}",
15 infallible
16 )
17 }
18}
19
20impl<IntoExit> From<Option<IntoExit>> for Exit
21where
22 IntoExit: Into<Exit>,
23{
24 fn from(option: Option<IntoExit>) -> Self {
25 option.map(Into::into).unwrap_or_else(Self::normal)
26 }
27}
28
29impl<IntoExit1, IntoExit2> From<Result<IntoExit1, IntoExit2>> for Exit
30where
31 IntoExit1: Into<Exit>,
32 IntoExit2: Into<Exit>,
33{
34 fn from(result: Result<IntoExit1, IntoExit2>) -> Self {
35 match result {
36 Ok(value) => value.into(),
37 Err(value) => value.into(),
38 }
39 }
40}