Change GetManyMutError to match T-libs-api decision

That is, differentiate between out-of-bounds and overlapping indices, and remove the generic parameter `N`.

I also exported `GetManyMutError` from `alloc` (and `std`), which was apparently forgotten.

Changing the error to carry additional details means LLVM no longer generates separate short-circuiting branches for the checks, instead it generates one branch at the end. I therefore changed the  code to use early returns to make LLVM generate jumps. Benchmark results between the approaches are somewhat mixed, but I chose this approach because it is significantly faster with ranges and also faster with `unwrap()`.
This commit is contained in:
Chayim Refael Friedman
2024-11-28 23:34:47 +02:00
parent 7e565cce6a
commit fa87a3e889
3 changed files with 34 additions and 28 deletions

View File

@@ -1076,4 +1076,4 @@ impl Error for crate::time::TryFromFloatSecsError {}
impl Error for crate::ffi::FromBytesUntilNulError {}
#[unstable(feature = "get_many_mut", issue = "104642")]
impl<const N: usize> Error for crate::slice::GetManyMutError<N> {}
impl Error for crate::slice::GetManyMutError {}