-
-
Save rust-play/6f58c354416c0c771c344c7b0c10b4a1 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
struct Foo<'a> { | |
tokens:Vec<i32>, | |
current_tok:Option<&'a i32>, | |
} | |
impl<'a> Foo<'a> { | |
fn new(tokens:Vec<i32>) -> Foo<'a> { | |
Foo { | |
tokens, | |
current_tok: None, | |
} | |
} | |
} | |
fn main() { | |
let mut foo = Foo::new(vec![1,2,5]); | |
foo.current_tok = foo.tokens.first(); | |
match foo.tokens.first() { | |
Some(x) => println!("{}",x), | |
_ => {}, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment