Why would an infallible operation return a Result?

88 points Miksel12

I was surprised to see that the set\_low() and set\_high() functions in the nrf\_hal return a Result type since flipping a register bit seems like a infallible operation. When I looked at the source code, I found this:

fn set_low(&mut self) -> Result<(), Self::Error> {
  unsafe {
    self.block().outclr.write(|w| w.bits(1u32 << self.pin()));
  }
  Ok(())
}

This seems to me like infallible code that can only return Ok(()).

So why would they choose to have it return a Result type? It only seems to be an annoyance since you have to handle the return type by either unwrapping it or assigning it.