Skip to content

Instantly share code, notes, and snippets.

@brandonpayton
Created April 11, 2020 07:41
Show Gist options
  • Save brandonpayton/09da105276fe9c6a5920e2daa7c3f33b to your computer and use it in GitHub Desktop.
Save brandonpayton/09da105276fe9c6a5920e2daa7c3f33b to your computer and use it in GitHub Desktop.
Rust generic type inference
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