Skip to content

Instantly share code, notes, and snippets.

@yhara
Created February 1, 2019 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yhara/a53475ba4d2c75d85caa16754e5254b1 to your computer and use it in GitHub Desktop.
Save yhara/a53475ba4d2c75d85caa16754e5254b1 to your computer and use it in GitHub Desktop.
struct Parser<'a> {
pub str: String,
pub current_token: Option<&'a str>,
}
impl<'a> Parser<'a> {
pub fn lex(&'a mut self) {
let tmp: &'a str = &self.str[0..1];
self.current_token = Some(tmp);
}
}
fn main() {
let mut parser = Parser{
str: "hello".to_string(),
current_token: None,
};
parser.lex();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment