-
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
Document that index
and index_mut
can panic
#84301
Conversation
r? @kennytm (rust-highfive has picked a reviewer for you, use r? to override) |
Since this is a property of the implementation, not the trait, should it maybe go on the implementations in libcore/liballoc? Or maybe the docs on the trait should specify that implementations may panic instead, not that they will? |
Do you mean it should go to https://doc.rust-lang.org/alloc/vec/struct.Vec.html#method.index, https://doc.rust-lang.org/alloc/string/struct.String.html#method.index and so on? It seems the documentation of those is automatically copied from
Good point, it's not enforced that they need to panic if the index is out of bounds so I will change that. |
@bors r+ rollup |
📌 Commit c86ffe9 has been approved by |
Document that `index` and `index_mut` can panic I thought this was noteworthy and I think a bit more explicitness does no harm.
Document that `index` and `index_mut` can panic I thought this was noteworthy and I think a bit more explicitness does no harm.
Document that `index` and `index_mut` can panic I thought this was noteworthy and I think a bit more explicitness does no harm.
Rollup of 12 pull requests Successful merges: - rust-lang#84013 (Replace all `fmt.pad` with `debug_struct`) - rust-lang#84119 (Move `sys::vxworks` code to `sys::unix`) - rust-lang#84212 (Replace `Void` in `sys` with never type) - rust-lang#84251 (fix 'const-stable since' for NonZeroU*::new_unchecked) - rust-lang#84301 (Document that `index` and `index_mut` can panic) - rust-lang#84365 (Improve the docstrings of the `Lto` struct.) - rust-lang#84378 (Fix broken doc link) - rust-lang#84379 (Add GAT related tests) - rust-lang#84380 (Write Rustdoc titles like "x in crate::mod - Rust") - rust-lang#84390 (Format `Struct { .. }` on one line even with `{:#?}`.) - rust-lang#84393 (Support `x.py doc std --open`) - rust-lang#84406 (Remove `delete` alias from `mem::drop`.) Failed merges: - rust-lang#84387 (Move `sys_common::poison` to `sync::poison`) r? `@ghost` `@rustbot` modify labels: rollup
I thought this was noteworthy and I think a bit more explicitness does no harm.