Created
November 11, 2019 19:42
-
-
Save rust-play/de2947cd737c7181880da7791e911f4c 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
pub enum Index<'a> { | |
S(&'a str), | |
I(usize), | |
} | |
impl<'a> From<&'a str> for Index<'a> { | |
fn from(s: &'a str) -> Self { | |
Self::S(s) | |
} | |
} | |
impl<'a> From<String> for Index<'a> { | |
fn from(s: String) -> Self { | |
Self::S(s.as_str()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment