Created
April 11, 2020 07:41
-
-
Save brandonpayton/09da105276fe9c6a5920e2daa7c3f33b to your computer and use it in GitHub Desktop.
Rust generic type inference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn get<T, U: From<T>>(s: T) -> U { | |
U::from(s) | |
} | |
fn main() { | |
let x: u64 = get(123u8); | |
println!("{:064b}", x); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment