Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::convert::TryInto;
- trait GenericTryInto {
- fn try_into_gen<T>(self) -> Result<T, Self::Error> where Self: TryInto<T> {
- self.try_into()
- }
- }
- impl<T: ?Sized> GenericTryInto for T {}
- fn foo(x: u32) {
- let x = x.try_into_gen::<u8>().expect("Not a u8");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement