Add FromIterator and IntoIterator impls for ThinVec#83821
Add FromIterator and IntoIterator impls for ThinVec#83821bors merged 1 commit intorust-lang:masterfrom
FromIterator and IntoIterator impls for ThinVec#83821Conversation
|
(rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Do you think it's worth adding a |
|
Inference was struggling in the |
This comment has been minimized.
This comment has been minimized.
I wouldn't personally add methods that are not used right now, if they can always be added on demand. |
|
Let me know before you r+ and I can squash. |
This comment has been minimized.
This comment has been minimized.
|
r=me with commits squashed. |
There was a problem hiding this comment.
It looks like this is also missing .push and .pop, I can add those separately. Seems weird that this derefs to a slice instead of a vec.
There was a problem hiding this comment.
You couldn't DerefMut to a vec in the None case.
These should make using `ThinVec` feel much more like using `Vec`. They will allow users of `Vec` to switch to `ThinVec` while continuing to use `collect()`, `for` loops, and other parts of the iterator API. I don't know if there were use cases before for using the iterator API with `ThinVec`, but I would like to start using `ThinVec` in rustdoc, and having it conform to the iterator API would make the transition *a lot* easier. I added a `FromIterator` impl, an `IntoIterator` impl that yields owned elements, and `IntoIterator` impls that yield immutable or mutable references to elements. I also added some unit tests for `ThinVec`.
|
@bors r=petrochenkov |
|
📌 Commit 09ff88b has been approved by |
|
☀️ Test successful - checks-actions |
These should make using
ThinVecfeel much more like usingVec.They will allow users of
Vecto switch toThinVecwhile continuingto use
collect(),forloops, and other parts of the iterator API.I don't know if there were use cases before for using the iterator API
with
ThinVec, but I would like to start usingThinVecin rustdoc,and having it conform to the iterator API would make the transition
a lot easier.
I added a
FromIteratorimpl, anIntoIteratorimpl that yields ownedelements, and
IntoIteratorimpls that yield immutable or mutablereferences to elements. I also added some unit tests for
ThinVec.