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

Add Writer::get_ref #322

Merged
merged 1 commit into from
May 31, 2023
Merged

Conversation

threecgreen
Copy link
Contributor

It's useful to be able to access the underlying writer without dropping Writer, for example, checking the position of an std::io::Cursor.

@BurntSushi
Copy link
Owner

get_ref seems okay, but I'm less sure about get_mut. It looks like a footgun to me, although a Reader does have it.

Does get_ref unblock your specific use case? If so, let's just go with that for now.

@threecgreen
Copy link
Contributor Author

Thanks for the quick response!

Yes, get_ref unblocks my specific use case.

@threecgreen threecgreen changed the title Add Writer::get_ref and Writer::get_mut Add Writer::get_ref May 31, 2023
src/writer.rs Outdated
pub fn get_ref(&self) -> &W {
self.wtr.as_ref().unwrap()
}

Copy link
Owner

Choose a reason for hiding this comment

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

Sorry, one more thing. Can you move this above into_inner to match the order of methods on csv::Reader? Thanks.

Copy link
Owner

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

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

Thanks!

@BurntSushi BurntSushi merged commit 0cf3f6c into BurntSushi:master May 31, 2023
@BurntSushi
Copy link
Owner

This PR is on crates.io in csv 1.2.2.

@threecgreen threecgreen deleted the get-ref-mut branch May 31, 2023 17:06
@threecgreen
Copy link
Contributor Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants