- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
          Add FromIterator and IntoIterator impls for ThinVec
          #83821
        
          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
Conversation
| (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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.