@@ -38,7 +38,7 @@ pub(crate) struct FileChecker {
3838 /// Utility for performing fragment checks in HTML files.
3939 fragment_checker : FragmentChecker ,
4040 /// Utility for checking wikilinks, indexes files in a given directory
41- wikilink_checker : WikilinkChecker ,
41+ wikilink_checker : Option < WikilinkChecker > ,
4242}
4343
4444impl FileChecker {
@@ -335,19 +335,26 @@ impl FileChecker {
335335
336336 // Initializes the index of the wikilink checker
337337 fn setup_wikilinks ( & self ) -> Result < ( ) , ErrorKind > {
338- self . wikilink_checker . setup_wikilinks_index ( )
338+ match & self . wikilink_checker {
339+ Some ( checker) => checker. setup_wikilinks_index ( ) ,
340+ None => Err ( ErrorKind :: WikilinkCheckerInit (
341+ "Initialization failed, no checker instantiated" . to_string ( ) ,
342+ ) ) ,
343+ }
339344 }
340345
341346 // Tries to resolve a link by looking up the filename in the wikilink index
342347 fn apply_wikilink_check ( & self , path : & Path , uri : & Uri ) -> Result < PathBuf , ErrorKind > {
343348 let mut path_buf = path. to_path_buf ( ) ;
344349 for ext in & self . fallback_extensions {
345350 path_buf. set_extension ( ext) ;
346- match self . wikilink_checker . contains_path ( & path_buf) {
347- None => {
348- trace ! ( "Tried to find wikilink {} at {}" , uri, path_buf. display( ) ) ;
351+ if let Some ( checker) = & self . wikilink_checker {
352+ match checker. contains_path ( & path_buf) {
353+ None => {
354+ trace ! ( "Tried to find wikilink {} at {}" , uri, path_buf. display( ) ) ;
355+ }
356+ Some ( resolved_path) => return Ok ( resolved_path) ,
349357 }
350- Some ( resolved_path) => return Ok ( resolved_path) ,
351358 }
352359 }
353360
0 commit comments