I am still pretty new to Rust and I have this function:
Edit: Here is a newer version of the function with the same issue as far as I can tell
pub fn new_from_file_path(path: &str) -> Parser {
let path_buf: PathBuf = PathBuf::from(path);
let absolute_path: PathBuf = std::fs::canonicalize(path_buf).unwrap();
let data: String = std::fs::read_to_string(absolute_path).unwrap();
let clone = data.clone();
let s_slice: &str = &clone[..];
return Parser::new_from_string_data(s_slice);
}
Here is the implementation of the new_from_string_data() function
pub fn new_from_string_data(data: &str) -> Parser {
let parser = Parser::new(data.chars());
return parser;
}
This is the struct definition for parser :
pub struct Parser<'a> {
tokenizer: Tokenizer<'a>,
}
Here is a screenshot of the error message I am getting
Any help would be greatly appreciated, please also let me know if more information is needed.