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:
parent
6c3d7f50ce
commit
6be18e3e3e
1 changed files with 1 additions and 1 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
fn first_word(s: &String) -> &str {
|
fn first_word(s: &str) -> &str {
|
||||||
let bytes = s.as_bytes();
|
let bytes = s.as_bytes();
|
||||||
|
|
||||||
for (i, &item) in bytes.iter().enumerate() {
|
for (i, &item) in bytes.iter().enumerate() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue