Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #[derive(Debug)]
- enum Hello {
- Bonjour,
- Nihao
- }
- trait SayHello<T> {
- fn hello(action: &str) -> Result<T, &'static str> ;
- }
- impl SayHello<Hello> for Hello {
- fn hello(action: &str) -> Result<Hello, &'static str> {
- match action {
- "bonjour" => Ok(Hello::Bonjour),
- "nihao" => Ok(Hello::Nihao),
- _ => Err("lol")
- }
- }
- }
- fn main() {
- println!("Hello, world!");
- let hello = Hello::hello("nihao");
- println!("ntm {:?}", hello)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement