-
-
Save sumeet/aeab2d0f666451d44a6873b5dc5a7292 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains hidden or 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
struct Assignment {} | |
enum CodeNode { | |
Assignment(Assignment), | |
} | |
enum CodeNodeRef<'a> { | |
Assignment(&'a Assignment), | |
} | |
impl<'a> From<&'a Assignment> for CodeNodeRef<'a> { | |
fn from(x: &'a Assignment) -> Self { | |
CodeNodeRef::Assignment(x) | |
} | |
} | |
impl<'a> From<&'a CodeNode> for CodeNodeRef<'a> { | |
fn from(x: &'a CodeNode) -> Self { | |
match x { | |
CodeNode::Assignment(y) => y.into(), | |
} | |
} | |
} | |
fn foo<'a>(x: impl Into<CodeNodeRef<'a>>) { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment