i tried the program myself, but this error is coming below :-
1156 | let user = replace_vowels(&word);
| ^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `str`
= note: all local variables must have a statically known size
= help: unsized locals are gated as an unstable feature
error[E0277]: the size for values of type `str` cannot be known at compilation time
--> src/main.rs:1157:33
|
1157 | println!("the new word is {}",user);
| ^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `str`
note: required by a bound in `ArgumentV1::<'a>::new_display`
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
the program is :-
fn main(){
let word: &str = "hello";
let user = replace_vowels(&word);
println!("the new word is {}",user);
}
fn replace_vowels(w : &str) -> str{
let vowel_lst = ["a","e","i","o","u"];
for mut i in w.iter(){
if i == "a" || i == "e" || i == "o" || i == "i" || i == "u"{
i = "*";
}
}
w
}
can someone help me to rectify this error? i dont know whether i did mistake in references or something?