【发布时间】:2021-07-08 02:54:55
【问题描述】:
pub fn get_header_authorization() -> (&str, &str) {
dotenv().ok();
let str = std::env::var("HEADER_AUTHORIZATION").expect("HEADER AUTHORIZATION must be set!");
let header:Vec<&str> = str.split('&').collect();
let (a, b) = (header[0], header[1]);
(a, b)
}
#[test]
fn test() {
let authorization = get_header_authorization();
assert_eq!(authorization.0, "Authorization")
}
error[E0106]: missing lifetime specifier
--> src\json_function.rs:173:45
|
173 | pub fn get_header_authorization() -> (&str, &str) {
| ^ expected named lifetime parameter
|
【问题讨论】:
-
你为什么返回
&str而不是String?