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

Consider renaming MappedWrite::unwrap to MappedWrite::into_inner #781

Open
edmorley opened this issue Feb 14, 2024 · 0 comments
Open

Consider renaming MappedWrite::unwrap to MappedWrite::into_inner #781

edmorley opened this issue Feb 14, 2024 · 0 comments

Comments

@edmorley
Copy link
Member

Whilst reviewing #721, I found initially thought the unwrap() in this usage was an unwrap() in the sense of Result::unwrap() and something that could panic:

            state: state::Section {
                write: self.state.write.unwrap(),
            },

Instead, it seems MappedWrite::unwrap in fact returns the inner writer, and can never panic.

Searching around for whether there was prior art we could base the naming on (returning some inner field), I found that BufWriter actually has an into_inner which does exactly what we're doing in MappedWrite::unwrap:
https://doc.rust-lang.org/std/io/struct.BufWriter.html#method.into_inner

As such, renaming to MappedWrite::into_inner seems to make sense to me?

@Malax Thoughts?

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

No branches or pull requests

1 participant