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

Container writers should panic if dropped without calling end() #740

Open
zslayton opened this issue Apr 10, 2024 · 0 comments
Open

Container writers should panic if dropped without calling end() #740

zslayton opened this issue Apr 10, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@zslayton
Copy link
Contributor

Dropping a container writer without calling end() can result in lost or corrupted Ion data. We should panic! to noisily prevent that. For example:

impl<'a, W: Write> Drop for TextContainerWriter_1_0<'a, W> {
fn drop(&mut self) {
// If the user didn't call `end`, the closing delimiter was not written to output.
// It's too late to call it here because we can't return a `Result`.
if !self.has_been_closed {
panic!(
"Container writer ({}) was dropped without calling `end()`.",
self.ion_type
);
}
}
}

@zslayton zslayton added the bug Something isn't working label Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant