Skip to content

Instantly share code, notes, and snippets.

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