string slicing: enhance API to accept string slices

This way, the API is more general and we can accept any kind of string
This commit is contained in:
laurens 2020-05-22 13:28:50 +02:00
parent 6c3d7f50ce
commit 6be18e3e3e

View file

@ -1,4 +1,4 @@
fn first_word(s: &String) -> &str {
fn first_word(s: &str) -> &str {
let bytes = s.as_bytes();
for (i, &item) in bytes.iter().enumerate() {