Skip to content

Commit 0b773c9

Browse files
committed
minor refactor of anchor implementation to be backward compatible
1 parent a4c3577 commit 0b773c9

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/book/book.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,12 @@ fn load_chapter<P: AsRef<Path>>(
262262
src_dir.join(link_location)
263263
};
264264
if !location.exists() {
265-
let file_name = location
266-
.file_name()
267-
.map(OsStr::to_str)
268-
.flatten()
269-
.map(String::from);
265+
let file_name =
266+
if let Some(Some(file_name_str)) = location.file_name().map(OsStr::to_str) {
267+
Some(String::from(file_name_str))
268+
} else {
269+
None
270+
};
270271
if let Some(name) = file_name {
271272
if name.contains("#") {
272273
let values = name.rsplitn(2, "#").collect::<Vec<_>>();

0 commit comments

Comments
 (0)