Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take advantage of smart Rust Lifetimes #56

Open
brandonLi8 opened this issue Apr 6, 2023 · 0 comments
Open

Take advantage of smart Rust Lifetimes #56

brandonLi8 opened this issue Apr 6, 2023 · 0 comments

Comments

@brandonLi8
Copy link
Owner

https://doc.rust-lang.org/book/ch10-03-lifetime-syntax.html
http://web.mit.edu/rust-lang_v1.25/arch/amd64_ubuntu1404/share/doc/rust/html/book/second-edition/ch19-02-advanced-lifetimes.html

One of the initial decisions was to use String types in enums/structs, which has propogated now that there are many more passes and there are many places where to_string and such are called when they shouldn't need to be.

I played around for a bit and found that I should at least:

  1. File type rename to "Context" which is the compilation context. This is the main struct which OWNS the content, file_name, etc Strings
  2. Tokens refer to &'a str instead of String. &'a refers to slices in context. Basically saying the Token cannot live longer than from where the slice comes from (aka context.content) (NO context dies first, token still refers), which is TRUE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant