Skip to content
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

Implement Write for Cursor<&mut Vec<u8>> #46830

Merged
merged 1 commit into from
Jan 10, 2018
Merged

Conversation

Diggsey
Copy link
Contributor

@Diggsey Diggsey commented Dec 18, 2017

Fixes #30132

r? @dtolnay (I'm just going through feature-accepted issues I swear 😛)

@dtolnay dtolnay added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Dec 19, 2017
@kennytm
Copy link
Member

kennytm commented Dec 20, 2017

Thanks for the PR! We’ll periodically check in on it to make sure that @dtolnay or someone else from the team reviews it soon.

@kennytm kennytm added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 20, 2017
Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! The implementation looks good to me. Let's run it by the rest of the libs team though.

@dtolnay
Copy link
Member

dtolnay commented Dec 25, 2017

@rust-lang/libs this adds the following impl. This is important for being able to write to a Vec owned by a Mutex or similar.

impl<'a> Write for Cursor<&'a mut Vec<u8>>

@rfcbot fcp merge

@rfcbot
Copy link

rfcbot commented Dec 25, 2017

Team member @dtolnay has proposed to merge this. The next step is review by the rest of the tagged teams:

No concerns currently listed.

Once these reviewers reach consensus, this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added the proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. label Dec 25, 2017
@dtolnay dtolnay added S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 3, 2018
@rfcbot
Copy link

rfcbot commented Jan 9, 2018

🔔 This is now entering its final comment period, as per the review above. 🔔

1 similar comment
@rfcbot
Copy link

rfcbot commented Jan 9, 2018

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels Jan 9, 2018
@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Jan 10, 2018

📌 Commit 77b3090 has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented Jan 10, 2018

⌛ Testing commit 77b3090 with merge 27ede55...

bors added a commit that referenced this pull request Jan 10, 2018
Implement `Write` for `Cursor<&mut Vec<T>>`

Fixes #30132

r? @dtolnay (I'm just going through `feature-accepted` issues I swear 😛)
@bors
Copy link
Contributor

bors commented Jan 10, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing 27ede55 to master...

@bors bors merged commit 77b3090 into rust-lang:master Jan 10, 2018
@est31
Copy link
Member

est31 commented Jan 10, 2018

Thank you @Diggsey !

@oconnor663
Copy link
Contributor

We might want to tweak the title here to replace T with u8, since this PR gets linked to by some recent announcements.

@kennytm kennytm changed the title Implement Write for Cursor<&mut Vec<T>> Implement Write for Cursor<&mut Vec<u8>> Mar 29, 2018
@clouds56
Copy link

Should we mention the behavior of resize in the document? (otherwise one might not sure if Cursor<&mut Vec<u8>> would do the same as Cursor<&mut [u8]>)

Cursors are used with in-memory buffers, anything implementing AsRef<[u8]>, to allow them to implement Read and/or Write, allowing these buffers to be used anywhere you might use a reader or writer that does actual I/O. the buffer of Cursor<&mut [u8]> would not be increased when the space runs out while Cursor<Vec<u8>> and Cursor<&mut Vec<u8>> would just like an actual file.

I'd like to provide File-like in-memory buffer to some API accept W: Write, it takes me time to find out I could use Cursor<&mut Vec<u8>> before I see this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement Read/Write on Cursor over &mut Vec
9 participants