Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait Convert<'a, T: 'a> {
- fn convert(&self) -> Option<T>;
- }
- struct MyStruct;
- impl<'a> Convert<'a, bool> for MyStruct {
- fn convert(&self) -> Option<bool> {
- Some(true)
- }
- }
- impl<'a> Convert<'a, usize> for MyStruct {
- fn convert(&self) -> Option<usize> {
- Some(1)
- }
- }
- fn main() {
- if let Some(_) = Convert::<usize>::convert(&MyStruct) {
- }
- }
Add Comment
Please, Sign In to add comment