@@ 19,17 19,22 @@ fn get_invoker_target<'a, K, V>(
players: &'a mut HashMap<K, V>,
invoker: &K,
target: &K
-) -> (&'a mut V, Option<&'a mut V>)
+) -> (&'a mut V, &'a mut V)
where
K: Eq + std::hash::Hash,
{
- if invoker == target {
- return (players.get_mut(invoker).unwrap(), None);
- }
unsafe {
+ // NOTE: soo... I don't really know the consequences of possibly
+ // having two mutable references to the same value, but I guess
+ // I'll find out!
+ // in many instances where people wanted multiple mutable references
+ // to Vec or HashMap values, they only gave one in wrappers like this,
+ // if the wanted values were the same.
+ // e.g. returning (V, None), if the keys were the same.
+
let invoker_ref = players.get_mut(invoker).unwrap() as *mut _;
let target_ref = players.get_mut(target).unwrap() as *mut _;
- (&mut *invoker_ref, Some(&mut *target_ref))
+ (&mut *invoker_ref, &mut *target_ref)
}
}