-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Don't use the word 'unwrap' to describe core 'unwrap' functions #68849
Conversation
r? @rkruppe (rust_highfive has picked a reviewer for you, use r? to override) |
Oh, note that the "main" Option::unwrap function says "Move the value ... ", so it already has better docs, but Result::unwrap uses the "unwrap" language. It could be nicer to mimic that functions docs for all the other unwraps. |
OK, I'm taking another pass at this to try to make all the unwrap docs more consistent. |
I pushed another commit that tries to make the various unwrap methods across Option and Result consistent in their language. It uses the "Move" language from the existing Option::unwrap docs, though I think it reads a bit awkwardly. I also changed two argument names in the Result methods, I didn't touch the unwrap_or_default docs. |
OK, realizing their are various non-unwrap methods that also use the "unwrap" language, I'm feeling a bit frustrated and indecisive. I think none of them should say "unwrap" (unless they are explicitly referencing the unwrap method) since a newbie could encounter any of them and have no idea what unwrap means. But I also think the "Moves the value I'm going to close this and rethink the whole thing. BBL... |
FWIW, "unwrap" also has a regular English meaning separate from its jargon meaning, i.e. to remove a wrapper / layer of wrapping around the thing you're really interested in. The idea is that types like But I do agree that there are some " |
I think |
Don't use the word "unwrap" to describe "unwrap" methods It's tautological, and "unwrap" is essentially Rust-specific jargon. I was teaching a newbie some Rust, and doing the usual hand-waving about error handling using unwrap. They asked what 'unwrap' means. I said look it up in the docs. The docs read (paraphrased) "unwrap unwraps". I was embarrassed. This changes all the Option/Result functions with unwrapping behavior to use a variation on a single description: > "Returns the contained `Some/Ok` value [or ...]." It also renames the closure of `Result::unwrap_or_else` to `default` for consistency with `Option`, and perhaps makes a few other small tweaks. Previous: rust-lang#68849
Don't use the word "unwrap" to describe "unwrap" methods It's tautological, and "unwrap" is essentially Rust-specific jargon. I was teaching a newbie some Rust, and doing the usual hand-waving about error handling using unwrap. They asked what 'unwrap' means. I said look it up in the docs. The docs read (paraphrased) "unwrap unwraps". I was embarrassed. This changes all the Option/Result functions with unwrapping behavior to use a variation on a single description: > "Returns the contained `Some/Ok` value [or ...]." It also renames the closure of `Result::unwrap_or_else` to `default` for consistency with `Option`, and perhaps makes a few other small tweaks. Previous: rust-lang#68849
Don't use the word "unwrap" to describe "unwrap" methods It's tautological, and "unwrap" is essentially Rust-specific jargon. I was teaching a newbie some Rust, and doing the usual hand-waving about error handling using unwrap. They asked what 'unwrap' means. I said look it up in the docs. The docs read (paraphrased) "unwrap unwraps". I was embarrassed. This changes all the Option/Result functions with unwrapping behavior to use a variation on a single description: > "Returns the contained `Some/Ok` value [or ...]." It also renames the closure of `Result::unwrap_or_else` to `default` for consistency with `Option`, and perhaps makes a few other small tweaks. Previous: rust-lang#68849
Don't use the word "unwrap" to describe "unwrap" methods It's tautological, and "unwrap" is essentially Rust-specific jargon. I was teaching a newbie some Rust, and doing the usual hand-waving about error handling using unwrap. They asked what 'unwrap' means. I said look it up in the docs. The docs read (paraphrased) "unwrap unwraps". I was embarrassed. This changes all the Option/Result functions with unwrapping behavior to use a variation on a single description: > "Returns the contained `Some/Ok` value [or ...]." It also renames the closure of `Result::unwrap_or_else` to `default` for consistency with `Option`, and perhaps makes a few other small tweaks. Previous: rust-lang#68849
It's tautological, and "unwrap" is essentially Rust-specific jargon.
I was teaching a newbie some Rust, and doing the usual hand-waving about error handling using unwrap. They asked what 'unwrap' means. I said look it up in the docs. The docs read (paraphrased) "unwrap unwraps". I was embarrassed.
This patch just changes the language to "consume", which is at least more general than "unwrap", has a clear English-language meaning, and is not the same word as the function names. It has the downside that "consuming" in the type system is still pretty Rust-specific and may not have obvious meaning in this context.