Why does Vec::swap_remove() return just T instead of Option<T>?
I'm so used to everything in rust having an explicit warning that if it can cause a panic, then it returns either Result<T, E> or Option<T>. So why not Vec::swap\_remove()?
Also, it feels like it would be a bit more "rusty" to do i.e.
let bar = myvec.swap\_remove(5).unwrap\_or\_else(|| todo!() )
Rather than:
let bar = if 5 <= myvec.len() { myvec.swap\_remove(5) } else { todo!() }
The latter also seems to be effectively doing the same bounds check twice, when it only needs to be done once. I've noticed that some other Vec methods are like this as well, such as Vec::remove().