Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mod colors {
- pub enum Color<'a> {
- Red,
- Blue,
- Other(&'a str),
- }
- }
- type Color = colors::Color<'static>;
- fn main() {
- let _s = "Hmm".to_string();
- let mut _c: Color = colors::Color::Red;
- // Fails as &_s is not 'static:
- //_c = colors::Color::Other(&_s)
- // Succeeds
- _c = colors::Color::Other("okay");
- }
Add Comment
Please, Sign In to add comment