main
use std::collections::HashMap;
use crate::math_parser::pconsts;
/// Math problems parser.
pub struct Parser {
pub string: &'static str
}
impl Parser {
/// Get given string.
pub fn get_str(&self) -> &str {
return self.string;
}
/// Get math problems separated by commas.
pub fn get_problems(&self) -> Vec<&str> {
return self.string.split(pconsts::parser_comma).collect();
}
/// Trim math problems.
pub fn trim_problems(&self, problems: Vec<&str>) -> Vec<&str> {
let trimed_problems: Vec<&str>;
for problem in problems {
trimed_problems.push(problem);
}
return trimed_problems;
}
// /// Parse math problems.
// pub fn parse(&self) -> Vec<HashMap<&str, &str>> {
// }
}
when compiling getting this error.
error[E0623]: lifetime mismatch
--> src\math_parser\parser.rs:29:16
|
22 | pub fn trim_problems(&self, problems: Vec<&str>) -> Vec<&str> {
| ---- ---------
| |
| this parameter and the return type are declared with different lifetimes...
...
29 | return trimed_problems;
| ^^^^^^^^^^^^^^^ ...but data from `problems` is returned here
How do I solve this?