【发布时间】:2019-01-16 13:05:29
【问题描述】:
考虑以下代码:
extern crate clap;
use clap::{App};
use std::io;
fn parse_argv() -> &'static clap::ArgMatches {
return App::new("example")
.get_matches()
}
fn main() -> io::Result<()> {
let matches = parse_argv();
Ok(())
}
这是错误:
error[E0106]: missing lifetime specifier
--> src/main.rs:6:29
|
6 | fn parse_argv() -> &'static clap::ArgMatches {
| ^^^^^^^^^^^^^^^^ help: consider giving it a 'static lifetime: `clap::ArgMatches + 'static`
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
这里有什么问题,我该如何解决?我想我做了编译器要求的,但错误不会消失。
【问题讨论】:
标签: rust borrow-checker