Guest User

Untitled

a guest
Mar 22nd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. mod colors {
  2. pub enum Color<'a> {
  3. Red,
  4. Blue,
  5. Other(&'a str),
  6. }
  7. }
  8.  
  9. type Color = colors::Color<'static>;
  10.  
  11. fn main() {
  12. let _s = "Hmm".to_string();
  13. let mut _c: Color = colors::Color::Red;
  14.  
  15. // Fails as &_s is not 'static:
  16. //_c = colors::Color::Other(&_s)
  17.  
  18. // Succeeds
  19. _c = colors::Color::Other("okay");
  20. }
Add Comment
Please, Sign In to add comment