A literal is a value that is literally written in the source code, like
a is not a string literal, because it is an identifier.
a happens to represent a variable of type
&'static str, which, in the first iteration of the loop, happens to be set to the value
"Something". But it is not a string literal, it's always an identifier.
&'static str is a
Copy type, so your question is still valid: Why can't you use
ani after the loop, if it's not consumed by the
println!? The answer is that the string itself is not consumed by the loop, but
ani is, because it's a
Vec<&'static str> and
Vec is not
Copy. After the loop,
ani doesn't exist anymore because
ani has been moved out of.
If you want to avoid moving out of
ani so that it can be used after the loop is over, you can iterate over it by reference as hellow mentioned.