I have searched and searched and none of what I've found applies even though superficially it looks like it should. Hopefully someone can help me keep my head from exploding.
Error:
`parts` does not live long enough
borrowed value does not live long enough
I am trying to use a string, split it and then use the pieces later in a loop. I know the error has something to do with the tokio::spawn, because if I remove that, then the errors go away, but I can't figure out what's causing the error.
let mut v4ips:Vec<Ifv4Addr> = Vec::new();
for ip in v4ips{
let parts = ip.ip.to_string();
if ip.netmask.to_string()==class_c{
let p :Vec<&str>=parts.split(".").collect();
for address in 0..255{
let v=p.clone();
let ip = ip.clone();
tokio::spawn(async move{
let stream = TcpStream::connect(format!("{}{}{}{}:{}",v[0],v[1],v[2],v[3],"2500")).await;
match stream{
Ok(a)=>{d.push(ip.clone())},
Err(e)=>{}
}
}
}
}
}