1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use std::convert::TryInto;
use std::fmt;

pub trait To {
    fn to<T>(self) -> T
    where
        Self: Into<T> + Sized,
    {
        self.into()
    }
}

impl<T> To for T {}

pub trait TryTo {
    fn try_to<T>(self) -> T
    where
        Self: TryInto<T> + Sized,
        <Self as TryInto<T>>::Error: fmt::Debug,
    {
        self.try_into().unwrap()
    }
}

impl<T> TryTo for T {}