You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to compile the code at this playpen gives the following error:
<anon>:18:20: 18:26 error: cannot infer an appropriate lifetime due to conflicting requirements
<anon>:18 match iter.next() {
^~~~~~
<anon>:17:5: 25:6 help: consider using an explicit lifetime parameter as shown: fn lookup(&self, mut iter: Box<Iterator<Item = Key<'b>>>) -> bool
There are a couple of issues here from my perspective:
The function signature suggested by the compiler cannot actually compile since it uses an undefined lifetime.
It's really unclear to me what the "conflicting requirements" are that the error message alludes to. Intuitively, I would have thought that the code should work as long as the lifetime of the iterator item is as long as the scope of the lookup method. In other words, my expectation would be that I can test whether a key is a member of the container without the lifetime of the instance of the key used for testing having to be as long as the lifetime of the container. However, that appears not to be the case, which seems counter-intuitive and limiting (since there doesn't appear to be an actual safety issue as far as I can see). It would be helpful to have scenarios like this discussed somewhere in the documentation. If such discussion already exists and I have overlooked it, my apologies.
The text was updated successfully, but these errors were encountered:
Trying to compile the code at this playpen gives the following error:
There are a couple of issues here from my perspective:
lookup
method. In other words, my expectation would be that I can test whether a key is a member of the container without the lifetime of the instance of the key used for testing having to be as long as the lifetime of the container. However, that appears not to be the case, which seems counter-intuitive and limiting (since there doesn't appear to be an actual safety issue as far as I can see). It would be helpful to have scenarios like this discussed somewhere in the documentation. If such discussion already exists and I have overlooked it, my apologies.The text was updated successfully, but these errors were encountered: