Hands-on Rust: How do I debug a call chain in Rust?

When running the program in chapter 8, “Implementing Combat”, the printout Health before attack was never printed so I assumed something was wrong in the call chain.

How would I go about debugging this call chain (ecs.entry_mut(*victim).unwrap()...)?

#[system] #[read_component(WantsToAttack)] #[read_component(Health)] pub fn combat(ecs: &mut SubWorld, commands: &mut CommandBuffer) { ... victims.iter().for_each(|(message, victim)| { if let Ok(mut health) = ecs .entry_mut(*victim) .unwrap() .get_component_mut::<Health>() { println!("Health before attack: {}", health.current); ... } commands.remove(*message); }); } 

After some comparing of source code, I found out that I had actually written read_component(Health) instead of write_component(Health).

#[system] #[read_component(WantsToAttack)] #[write_component(Health)] pub fn combat(ecs: &mut SubWorld, commands: &mut CommandBuffer) { ... } 

This is my first encounter with Rust but I was surprised that this error slipped by the compiler. I expected similar error as if I hade left out some mut