Hi,
I am trying to create a struct with its elements pointing to a vector and a hashmap that I intend to use later. I am getting expected named lifetime parameter
error while decalring the struct, and I can not seem to figure out this.
This issue seems to be similar to the one explianed in [the book](https://doc.rust-lang.org/stable/book/ch10-03-lifetime-syntax.html)
but still I have issues. Could some one please help me where exactly should I declare static
or other lifetimes?
use std::collections::HashMap;
fn main(){
let filenames: Vec<String> = vec!("foo.txt".to_string(), "bar.txt".to_string());
let mut chrdb: HashMap<String, u64> = HashMap::new();
chrdb.insert("chr1".to_string(), 10000);
chrdb.insert("chr2".to_string(), 20000);
chrdb.insert("chr3".to_string(), 30000);
let ct = Chrtree::new(&filenames, &chrdb);
println!("{:?}", ct);
}
struct Chrtree<'a> {
files: &'a Vec<String>,
chrlens: &'a HashMap<std::string::String, u64>,
}
impl<'a> Chrtree<'a> {
fn new(files: &Vec<String>, chrlens: &HashMap<String, u64>) -> &'a Chrtree {
Chrtree { files, chrlens }
}
}