Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Code shared from the Rust Playground
fn foo<T : std::convert::Into<usize>>(d : &T) -> usize {
d.into()
}
struct Bar {
a : usize
}
impl std::convert::Into<usize> for Bar {
fn into(self) -> usize {
self.a
}
}
fn main() {
let bar = Bar { a : 15 };
assert!(foo(&bar) == 15);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.