run_search

Function run_search 

Source
pub fn run_search(query: SearchQuery) -> Result<SearchResult>
Expand description

Main orchestrator function that coordinates the entire search workflow

This function:

  1. Searches for translation entries matching the query text
  2. Extracts translation keys from YAML files
  3. Finds code references for each translation key
  4. Returns a SearchResult with all findings

§Rust Book Reference

Chapter 9.2: Recoverable Errors with Result https://doc.rust-lang.org/book/ch09-02-recoverable-errors-with-result.html

§Educational Notes - The #[must_use] Attribute

The #[must_use] attribute causes a compiler warning if the Result is ignored:

run_search(query);  // WARNING: unused Result that must be used

This prevents accidentally ignoring errors. You must either:

  • Handle the error: match run_search(query) { Ok(r) => ..., Err(e) => ... }
  • Propagate with ?: let result = run_search(query)?;
  • Explicitly ignore: let _ = run_search(query);

Why this matters:

  • Rust doesn’t have exceptions - errors must be explicitly handled
  • Ignoring a Result means ignoring potential errors
  • #[must_use] makes error handling explicit and intentional