To be able to mutate it, you need to have a String
, not just a &'static str
as you get from string literals. Or more precisely, you need a &mut str
which is usually obtained by mutably borrowing from a String
.
I.e. ["red", "yellow", "blue"]
is a [&'static str; 3]
.
Use e.g. ["red".to_string(), "yellow".to_string(), "blue".to_string()]
instead.
Also *color.make_ascii_uppercase()
is interpreted as *(color.make_ascii_uppercase())
. You probably mean (*color).make_ascii_uppercase()
instead, but you don’t actually need to dereference a variable in order to call a method on it, so color.make_ascii_uppercase()
is going to work fine.
Finally that println
statement is not inside of the main
function and you’ll need {:?}
to print an array.