stefans_utils/
unwrap_into.rs

1use core::fmt;
2
3pub trait UnwrapInto<T> {
4    fn unwrap_into(self) -> T;
5    fn expect_into(self, message: &str) -> T;
6}
7
8impl<T, E: fmt::Debug, S: TryInto<T, Error = E>> UnwrapInto<T> for S {
9    fn unwrap_into(self) -> T {
10        self.try_into().unwrap()
11    }
12
13    fn expect_into(self, message: &str) -> T {
14        self.try_into().expect(message)
15    }
16}