this post was submitted on 20 Aug 2026
42 points (100.0% liked)
Rust
8239 readers
31 users here now
Welcome to the Rust community! This is a place to discuss about the Rust programming language.
Wormhole
Credits
- The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
founded 3 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
substr_rangeis awesome. There's so many times where knowing where in the string the substring is from would have been helpful, especially with parsing. For example, you can calculate where in the input a particular token comes from and even select the full original source that matches a particular pattern by parsing, then calculating what was parsed from the cursor's new position (what's the remainder's range?) and the starting position (what was the range before parsing the pattern?).