dasunpubudumal / rlox_lexer

Lox language lexer written in Rust https://craftinginterpreters.com/contents.html
0 stars 0 forks source link

Optimise substring functionality in the lexer #2

Open dasunpubudumal opened 2 months ago

dasunpubudumal commented 2 months ago

Currently, since std::string::String does not contain a substring function, we have adhered to a more "unconventional" approach to substring a string. The approach is as follows:

  1. Declare a vector Vec<char> and push characters to the vector through an iterator.
  2. Use String::from_iter function to convert the vector into a string.

There are other more traditional approaches to this; examples such as Java's String.substring function comes to mind.

The idea behind this issue is to create a custom utility function for substring or bring in a crate and integrate it to the current codebase.