Skip to content

Commit 3fb1c37

Browse files
committed
Add comments
1 parent 57a24ed commit 3fb1c37

File tree

1 file changed

+3
-2
lines changed
  • notify-debouncer-full/src

1 file changed

+3
-2
lines changed

notify-debouncer-full/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ impl<T: FileIdCache> DebounceDataInner<T> {
275275
// get the path of the event
276276
.map(|(path, _)| path.clone())
277277
{
278+
// unwraps are safe because only paths for existing queues with at least one event are returned by the query above
278279
let event = self
279280
.queues
280281
.get_mut(&path)
@@ -301,7 +302,7 @@ impl<T: FileIdCache> DebounceDataInner<T> {
301302

302303
events_expired.push(event);
303304
} else {
304-
self.queues.get_mut(&path).unwrap().events.push_front(event);
305+
self.queues.get_mut(&path).unwrap().events.push_front(event); // unwrap is safe because only paths for existing queues are returned by the query above
305306

306307
break;
307308
}
@@ -505,7 +506,7 @@ impl<T: FileIdCache> DebounceDataInner<T> {
505506

506507
if let Some(target_queue) = self.queues.get_mut(&event.paths[0]) {
507508
if target_queue.was_removed() {
508-
let event = target_queue.events.pop_front().unwrap();
509+
let event = target_queue.events.pop_front().unwrap(); // unwrap is safe because `was_removed` implies that the queue is not empty
509510
source_queue.events.push_front(event);
510511
}
511512

0 commit comments

Comments
 (0)