-
-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lifetime constraints on e.g. ByteSlice::splitn_str
are too restrictive
#45
Comments
Fixing this is a breaking change, so I'm putting this in the 1.0 milestone. |
Out of educational interest, could you detail why that is so? Intuitively, that doesn't seem like so to me. |
Seems to me like it requires the iterator type to be parameterized over two lifetimes instead of the single one it has today. Adding a new non-default type parameter is a breaking change. |
Oh, right. Makes sense. Maybe it would be worth returning an impl Iterator for 1.0? |
No. Because then how do you impl things like DoubleEndedIterator? Or FusedIterator? You'd have to get everything right up front. Returning impl Trait in public APIs isn't a good idea unless you need it for unnamed types. |
In a few places I must have got lazy when defining the iterator types and forced haystacks and needles/splitters to always have the same lifetime. This works in most cases, but #45 shows a case where it breaks down. To fix it, we just make sure we represent all of our lifetimes in our types. Note that #45 was reported against our split types, but we also have this issue with our find types too. Indeed, our split types are built on top of our find types, so we just fix everything. This is a breaking change since we are adding a new lifetime parameter to several public API types. Fixes #45
They prevent things like:
The splitter doesn't need to have the same lifetime as the the slice that is being split.
The text was updated successfully, but these errors were encountered: