mirror of
https://github.com/rust-lang-cn/book-cn.git
synced 2025-01-23 07:20:20 +08:00
21 lines
848 B
Plaintext
21 lines
848 B
Plaintext
$ cargo build
|
|
Compiling minigrep v0.1.0 (file:///projects/minigrep)
|
|
error[E0106]: missing lifetime specifier
|
|
--> src/lib.rs:28:51
|
|
|
|
|
28 | pub fn search(query: &str, contents: &str) -> Vec<&str> {
|
|
| ---- ---- ^ expected named lifetime parameter
|
|
|
|
|
= help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `query` or `contents`
|
|
help: consider introducing a named lifetime parameter
|
|
|
|
|
28 | pub fn search<'a>(query: &'a str, contents: &'a str) -> Vec<&'a str> {
|
|
| ^^^^ ^^^^^^^ ^^^^^^^ ^^^
|
|
|
|
error: aborting due to previous error
|
|
|
|
For more information about this error, try `rustc --explain E0106`.
|
|
error: could not compile `minigrep`
|
|
|
|
To learn more, run the command again with --verbose.
|