Hacker News new | past | comments | ask | show | jobs | submit login

Passing both a &[String] and an index into the function is duplicative, because a slice already has an index in it (the start point). It would be cleaner to just use `tokens.split_first()` to yank the first token off the list, which gives you both that first token plus the remainder, then you can pass the remainder into subsequent calls, and return the remainder at the end when you're done. Or, heck, you could even take a `&mut &[String]` instead, allowing you to mutate the slice directly and not have to return anything.



This is a great suggestion eridius! I'll update it to use split_first.

Note: updated the essay and left a thanks to you :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: