into_this/
lib.rs

1//! Ever been in a situation where you needed `x.into()` but rust couldn't infer the type?
2//! Maybe you tried `x.into::<T>()` but it didn't work because the generic is in the wrong place?
3//! You considered `Into::into::<T>(x)`, but it was really ugly?
4//! 
5//! With this crate, you can import the [`IntoThis`] trait, which is implemented for all types,
6//! and then use `x.into_this::<T>()`.  So much cleaner!
7//! 
8//! Also works with try_into: `x.try_into_this::<T>()`
9
10
11pub trait IntoThis {
12    fn into_this<T>(self) -> T where Self: Into<T> {
13        self.into()
14    }
15    
16    fn try_into_this<T>(self) -> Result<T, Self::Error> where Self: TryInto<T> {
17        self.try_into()
18    }
19}
20
21impl<T> IntoThis for T { }