Skip to content

Commit 99ad441

Browse files
committed
Fixes panic on directory scan (ardaku#36)
1 parent 2e46ffb commit 99ad441

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/image_cache/directory.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pub struct Directory {
7171
/// Maps file indicies to indicies for the `curr_image_idx`.
7272
/// This is relevant when the current image is given by its name
7373
/// when it will first be located by its file index.
74-
file_i_to_img_i: Vec<Option<u32>>,
74+
file_i_to_img_i: Vec<Option<usize>>,
7575

7676
/// A monotonically increasing integer used for identifying
7777
/// each load request
@@ -331,15 +331,15 @@ impl Directory {
331331
for _ in (last_file_i + 1) as usize..curr_file_i {
332332
self.file_i_to_img_i.push(None);
333333
}
334-
self.file_i_to_img_i.push(Some(curr_img_i as u32));
334+
self.file_i_to_img_i.push(Some(curr_img_i));
335335
last_file_i = curr_file_i as isize;
336336
}
337337
self.set_image_index_from_file_index();
338338
}
339339

340340
fn set_image_index_from_file_index(&mut self) {
341-
if let Some(img_idx) = self.file_i_to_img_i.get(self.curr_file_idx) {
342-
self.curr_image_idx = img_idx.unwrap() as usize;
341+
if let Some(Some(img_idx)) = self.file_i_to_img_i.get(self.curr_file_idx) {
342+
self.curr_image_idx = *img_idx;
343343
}
344344
}
345345

0 commit comments

Comments
 (0)