I have a very simple method. The first argument takes in vector components (\"A\", 5, 0) and I will compare this to every element of another vector to see if they have the s
So the problem comes from the fact that vector
has two inferred lifetimes, one for vector
itself (the &Vec
part) and one for the &str
inside the vector. You also have an inferred lifetime on x
, but that really inconsequential.
To fix it, just specify that the returned &str
lives as long as the &str
in the vector:
fn is_same_space<'a>( // Must declare the lifetime here
x: &str, // This borrow doesn't have to be related (x isn't even used)
y1: i32, // Not borrowed
p: i32, // Not borrowed or used
vector: &'a Vec<(&'a str, i32, i32)> // Vector and some of its data are borrowed here
) -> &'a str { // This tells rustc how long the return value should live
...
}