Advertisement
Guest User

Untitled

a guest
Jan 16th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.48 KB | None | 0 0
  1. use std::collections::HashMap;
  2.  
  3. #[derive(Debug)]
  4. pub enum Toto {
  5.     Bli,
  6.     Bla,
  7.     Top
  8. }
  9.  
  10. type Env = HashMap<String, Toto>;
  11.  
  12. fn get(key: &String, e: &Env) -> Toto {
  13.     match e.get(key) {
  14.         Some(t) => {
  15.             let x = t.clone();
  16.             x // x has type &Toto instead of the expected(?) Toto
  17.               // if Toto derives Clone, then x has type Toto, as expected
  18.         },
  19.         None => Toto::Top
  20.     }
  21. }
  22.  
  23. fn main() {
  24.     println!("Hello, world!");
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement