From 6be18e3e3e39f7a1caa24154773b0ca7a17930a7 Mon Sep 17 00:00:00 2001 From: laurens Date: Fri, 22 May 2020 13:28:50 +0200 Subject: [PATCH] string slicing: enhance API to accept string slices This way, the API is more general and we can accept any kind of string --- string_slicing/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/string_slicing/src/main.rs b/string_slicing/src/main.rs index 566db74..f7bcad9 100644 --- a/string_slicing/src/main.rs +++ b/string_slicing/src/main.rs @@ -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() {