Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait Into_<T> {
- fn into(self) -> T;
- }
- impl Into_<i32> for i8 {
- fn into(self) -> i32 { self as i32 }
- }
- impl Into_<i32> for bool {
- fn into(self) -> i32 { self as i32 }
- }
- fn abs_i32<T>(a: T) -> i32
- where T: Into_<i32>
- {
- a.into().abs()
- }
- fn main() {
- println!("{} {}", abs_i32(true), abs_i32(false));
- println!("{}", abs_i32(-100i8));
- // 1i32 as bool;
- true as i32;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement