'what is different between &[&str] with &Vec<&str> in rust? [duplicate]

When I do exercise in rustlings, I found that exercise:

pub fn capitalize_words_string(words: &[&str]) -> String {}

i try to change function to

pub fn capitalize_words_string(words: &Vec<&str>) -> String {}

It also works properly, So my question is what is different between &[&str] with &Vec<&str> in rust? Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source