Skip to content

Commit a7af010

Browse files
committed
Fixup safety comment
1 parent f583724 commit a7af010

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/leds.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,11 @@ impl<'a> Iterator for LedsMutIterator<'a> {
196196
} else {
197197
let current = unsafe {
198198
//Safety: Each branch is only executed once,
199+
// and only if there are elements left to be returned,
199200
// so we can not possibly alias a mutable reference.
200-
// Oddly, this depends on DoubleSidedIterator also being implemented correctly.
201+
// This depends on DoubleEndedIterator and ExactSizedIterator being implemented correctly.
202+
// If len() does not return the correct number of remaining elements,
203+
// this becomes unsound.
201204
match self.index {
202205
0 => Some(&mut *(&mut self.leds.ld3 as *mut _)), //N
203206
1 => Some(&mut *(&mut self.leds.ld5 as *mut _)), //NE

0 commit comments

Comments
 (0)