Skip to contentSlop Block

prefer-early-continue

Warning

When a loop body is a single if, invert the condition and continue early.

fn run(users: &[User]) {	for user in users {		if user.active {The whole loop body sits inside one if			validate(user);			store(user);		}	}}
// ast-grep-ignore: prefer-early-continue-rust

How to fix

Invert the condition and continue, then write the rest of the body one level up.