Created
December 3, 2018 05:25
-
-
Save rust-play/6e4e323646c16d71389e5892447a53e2 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
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
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