#![allow(unused_variables)]
fn main() {
fn first_word(s: &String) -> &str {
let bytes = s.as_bytes();
for (i, &item) in bytes.iter().enumerate() {
if item == b' ' {
return &s[0..i];
}
}
&s[..]
}
}
In the above code, we are using "s.as_bytes();" method but actually in the function parameter we are getting only reference of the String then how can we able to convert it value as byte and assign it to byte variable. New to Programming sorry if my question is silly.