mirror of
https://git.pumpin.online/funkpower/catena.git
synced 2026-10-23 03:07:13 +00:00
chunkmd: say rfind, which is what this was doing
This commit is contained in:
@@ -179,9 +179,11 @@ impl<'a> ChapterIndex<'a> {
|
|||||||
/// per page in every chapter's span: a single mistyped marker reading
|
/// per page in every chapter's span: a single mistyped marker reading
|
||||||
/// `<!-- Page 20231115 -->` would ask for a gigabyte of them.
|
/// `<!-- Page 20231115 -->` would ask for a gigabyte of them.
|
||||||
pub fn chapter_of_page(chapters: &[Chapter], page: u32) -> Option<&str> {
|
pub fn chapter_of_page(chapters: &[Chapter], page: u32) -> Option<&str> {
|
||||||
|
// The last chapter that covers the page, not the first: chapters can
|
||||||
|
// nest, and the innermost one is the one a reader would name.
|
||||||
chapters
|
chapters
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|chapter| {
|
.rfind(|chapter| {
|
||||||
let Some(start) = chapter.start_page else {
|
let Some(start) = chapter.start_page else {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
@@ -193,7 +195,6 @@ pub fn chapter_of_page(chapters: &[Chapter], page: u32) -> Option<&str> {
|
|||||||
};
|
};
|
||||||
(start..=end.max(start)).contains(&page) && end >= start
|
(start..=end.max(start)).contains(&page) && end >= start
|
||||||
})
|
})
|
||||||
.next_back()
|
|
||||||
.map(|chapter| chapter.title.as_str())
|
.map(|chapter| chapter.title.as_str())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user