rust/library/core/src
Matthias Krüger 82beeabf54
Rollup merge of #96033 - yaahc:expect-elaboration, r=scottmcm
Add section on common message styles for Result::expect

Based on a question from https://github.com/rust-lang/project-error-handling/issues/50#issuecomment-1092339937

~~One thing I haven't decided on yet, should I duplicate this section on `Option::expect`, link to this section, or move it somewhere else and link to that location from both docs?~~: I ended up moving the section to `std::error` and referencing it from both `Result::expect` and `Option::expect`'s docs.

I think this section, when combined with the similar update I made on [`std::panic!`](https://doc.rust-lang.org/nightly/std/macro.panic.html#when-to-use-panic-vs-result) implies that we should possibly more aggressively encourage and support the "expect as precondition" style described in this section. The consensus among the libs team seems to be that panic should be used for bugs, not expected potential failure modes. The "expect as error message" style seems to align better with the panic for unrecoverable errors style where they're seen as normal errors where the only difference is a desire to kill the current execution unit (aka erlang style error handling). I'm wondering if we should be providing a panic hook similar to `human-panic` or more strongly recommending the "expect as precondition" style of expect message.
2022-05-26 20:59:40 +02:00
..
alloc Remove potentially misleading realloc parenthetical 2022-05-14 22:30:14 -05:00
array Stabilize core::array::from_fn 2022-05-20 11:04:13 -03:00
async_iter
char
convert
ffi
fmt Auto merge of #94530 - tmiasko:alignment-impls, r=dtolnay 2022-05-21 19:49:51 +00:00
future
hash Auto merge of #95960 - jhpratt:remove-rustc_deprecated, r=compiler-errors 2022-05-09 04:47:30 +00:00
iter Auto merge of #95602 - scottmcm:faster-array-intoiter-fold, r=the8472 2022-05-14 03:12:53 +00:00
macros Make write/print macros eagerly drop temporaries 2022-05-22 16:11:08 -07:00
mem Auto merge of #95960 - jhpratt:remove-rustc_deprecated, r=compiler-errors 2022-05-09 04:47:30 +00:00
num Rollup merge of #96129 - mattheww:2022-04_float_rounding, r=Dylan-DPC 2022-05-23 15:11:02 +02:00
ops
panic
prelude
ptr Auto merge of #94954 - SimonSapin:null-thin3, r=yaahc 2022-05-25 13:58:51 +00:00
slice Rollup merge of #97363 - wackbyte:sliceindex-doc-typo, r=JohnTitor 2022-05-25 07:08:44 +09:00
str Rollup merge of #97190 - SylvainDe:master, r=Dylan-DPC 2022-05-21 11:39:48 +02:00
sync Rollup merge of #97026 - Nilstrieb:make-atomic-debug-relaxed, r=scottmcm 2022-05-25 07:31:42 +02:00
task Rollup merge of #93966 - rkuhn:patch-1, r=tmandry 2022-05-25 07:08:41 +09:00
unicode
any.rs
ascii.rs
asserting.rs [RFC 2011] Library code 2022-05-22 07:18:32 -03:00
bool.rs
borrow.rs
cell.rs Stabilize cell_filter_map 2022-05-23 18:04:53 +09:00
clone.rs
cmp.rs
default.rs
hint.rs
internal_macros.rs
intrinsics.rs explain how to turn integers into fn ptrs 2022-05-23 18:47:08 +02:00
lazy.rs
lib.rs [RFC 2011] Library code 2022-05-22 07:18:32 -03:00
marker.rs
option.rs Rollup merge of #96033 - yaahc:expect-elaboration, r=scottmcm 2022-05-26 20:59:40 +02:00
panic.rs
panicking.rs
pin.rs
primitive_docs.rs Rollup merge of #97321 - RalfJung:int-to-fnptr, r=Dylan-DPC 2022-05-24 15:58:26 +02:00
primitive.rs
result.rs Rollup merge of #96033 - yaahc:expect-elaboration, r=scottmcm 2022-05-26 20:59:40 +02:00
time.rs
tuple.rs
unit.rs