use crate::{MoveError, Result};
pub trait Many<'a, Key> {
type Ref: 'a;
fn try_move_ref(&mut self, key: Key) -> Result<Self::Ref>;
#[track_caller]
fn move_ref(&mut self, key: Key) -> Self::Ref {
match self.try_move_ref(key) {
Ok(result) => result,
Err(error) => move_panic(error),
}
}
type Mut: 'a;
fn try_move_mut(&mut self, key: Key) -> Result<Self::Mut>;
#[track_caller]
fn move_mut(&mut self, key: Key) -> Self::Mut {
match self.try_move_mut(key) {
Ok(option) => option,
Err(error) => move_panic(error),
}
}
}
#[cold]
#[track_caller]
fn move_panic(error: MoveError) -> ! {
panic!("{}", error)
}