Skip to content

Commit

Permalink
Merge #413
Browse files Browse the repository at this point in the history
413: Correct eb3b96b with a useful function signature for try_wait r=jonas-schievink a=nospam2678

This is embarrassing. It appears my quality assurance for #412, while existent, was way flawed and insufficient.

Having a `try_` method take ownership over self makes it impossible call it more than once. Clearly a mutable reference was what was indented and required to actually make the method meaningful.

It would be a good idea to either merge this PR, or revert the previous one, prior to making the next release.

Co-authored-by: Martin <[email protected]>
  • Loading branch information
bors[bot] and Martin authored Nov 24, 2022
2 parents afda587 + 5b4530d commit 939c017
Showing 1 changed file with 0 additions and 14 deletions.
14 changes: 0 additions & 14 deletions nrf-hal-common/src/i2s.rs
Original file line number Diff line number Diff line change
Expand Up @@ -693,20 +693,6 @@ impl<B> Transfer<B> {
}
}

/// Attempts to return the buffer if the transfer is done.
pub fn try_wait(mut self) -> Option<(B, I2S)> {
if self.is_done() {
let inner = self
.inner
.take()
.unwrap_or_else(|| unsafe { core::hint::unreachable_unchecked() });
compiler_fence(Ordering::Acquire);
Some((inner.buffer, inner.i2s))
} else {
None
}
}

/// Blocks until the transfer is done and returns the buffer.
pub fn wait(mut self) -> (B, I2S) {
while !self.is_done() {}
Expand Down

0 comments on commit 939c017

Please sign in to comment.