Open dev-ardi opened 2 months ago
A fn in Chars<'a> that skips until it finds a specific char and returns the &'a str while it was skipping.
For example:
"I like bananas" ^ Chars is here
let subslice = my_chars.take_str(' '); assert_eq(subslice, "like"); "I like bananas" ^ Chars is here
There's currently no ergonomic way of doing this, it's possible but not something that feels supported.
While iterating over chars it's not the most ergonomic thing to find individual words, or to get subslices.
fn take_str(&mut self) -> &str
Please fill out the motivation section more. I would like to see a real example of its use.
It also looks like your prose description of its behavior doesn't match the behavior shown in your code snippet.
Proposal
A fn in Chars<'a> that skips until it finds a specific char and returns the &'a str while it was skipping.
For example:
Problem statement
There's currently no ergonomic way of doing this, it's possible but not something that feels supported.
Motivating examples or use cases
While iterating over chars it's not the most ergonomic thing to find individual words, or to get subslices.
Solution sketch