#[cfg(feature = "alloc")]
use crate::alloc_prelude::*;
use core::ops::IndexMut;
pub trait IndexMut2<I>: IndexMut<I> {
fn index_mut2(&mut self, i: usize, j: usize) -> (&mut Self::Output, &mut Self::Output);
#[inline]
fn index_mut_const(&mut self, i: usize, j: usize) -> (&mut Self::Output, &Self::Output) {
let (a, b) = self.index_mut2(i, j);
(a, &*b)
}
}
#[cfg(feature = "alloc")]
impl<T> IndexMut2<usize> for Vec<T> {
#[inline]
fn index_mut2(&mut self, i: usize, j: usize) -> (&mut T, &mut T) {
self.as_mut_slice().index_mut2(i, j)
}
}
impl<T> IndexMut2<usize> for [T] {
#[inline]
fn index_mut2(&mut self, i: usize, j: usize) -> (&mut T, &mut T) {
assert!(i != j, "Unable to index the same element twice.");
let [a, b] = self.get_disjoint_mut([i, j]).expect("Index out of bounds.");
(a, b)
}
}