Works for me:
#[derive(Debug)]
struct Input<'a>{
words: Vec<&'a str>,
phrase: &'a str,
}
fn main() {
let s="foo bar baz";
let input = Input {
words: s.split_whitespace().collect(),
phrase: s,
};
dbg!(input);
}
Compiling playground v0.0.1 (/playground)
Finished dev [unoptimized + debuginfo] target(s) in 1.15s
Running `target/debug/playground`
[src/main.rs:13] input = Input {
words: [
"foo",
"bar",
"baz",
],
phrase: "foo bar baz",
}