-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Improve slice indexing assertion #29984
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
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
str uses a separate function to put the formatting there |
Yeah I think the If, however, a concrete function in libcore were provided (e.g. not generic), then it could be as fancy as it wants! |
That should be marked |
@Manishearth might as well. |
cae8692
to
a1ff4b4
Compare
a1ff4b4
to
5c873be
Compare
Updated. Error message could be improved. |
I'd like to have the message print out the index and length values like it does elsewhere, but I'm not sure how to do that without affecting perf here. Will `assert!(cond, "index out of bounds got {} but len is ", idx, len)` make things slower? It calls `panic_fmt` which is marked as cold but also calls `format_args!`, and I don't know if that allocates or does any heavy lifting. cc @alexcrichton @gankro
I'd like to have the message print out the index and length values like it does elsewhere, but I'm not sure how to do that without affecting perf here. Will
assert!(cond, "index out of bounds got {} but len is ", idx, len)
make things slower? It callspanic_fmt
which is marked as cold but also callsformat_args!
, and I don't know if that allocates or does any heavy lifting.cc @alexcrichton @gankro