stefans-utils 0.12.0

A collection of useful Rust utility functions, types, and traits.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use core::fmt;

pub trait UnwrapInto<T> {
    fn unwrap_into(self) -> T;
    fn expect_into(self, message: &str) -> T;
}

impl<T, E: fmt::Debug, S: TryInto<T, Error = E>> UnwrapInto<T> for S {
    fn unwrap_into(self) -> T {
        self.try_into().unwrap()
    }

    fn expect_into(self, message: &str) -> T {
        self.try_into().expect(message)
    }
}