Ignore return value from statement in match arm

How do I ignore the return expression in the RemoveEntity(index) arm of the match expression?

pub fn update(&self) {
    while !self.operations.borrow_mut().is_empty() {
        match self.operations.borrow_mut().pop().unwrap() {
            AddEntity(entity) => self.entities.borrow_mut().push(entity.clone()),
            RemoveEntity(index) => {self.entities.borrow_mut().remove(index); ()},
        }
    }
}

My approach using the curlies and returning the unit type works but it feels clunky. Is there a better way?

You can remove the () -- this is already the implicit value of a block after a semicolon.

One way without a block is drop(expr), since that consumes the value and returns nothing.

1 Like