(self, locale: Locale, search: &Search)
| 595 | } |
| 596 | |
| 597 | pub fn to_search_match(self, locale: Locale, search: &Search) -> Result<SearchMatch> { |
| 598 | let normalized = &search.normalized; |
| 599 | let display_string = self.display_string(locale); |
| 600 | let search_string = Phrase::parse(&display_string); |
| 601 | |
| 602 | match self { |
| 603 | Self::Link { .. } => Ok(SearchMatch { |
| 604 | sort_key: SortKey( |
| 605 | Kind::Link, |
| 606 | &search_string != normalized, |
| 607 | display_string, |
| 608 | self.id().to_owned(), |
| 609 | ), |
| 610 | kind: Kind::Link, |
| 611 | object: self, |
| 612 | }), |
| 613 | |
| 614 | Self::Topic { .. } => { |
| 615 | let topic_id = self.id(); |
| 616 | let explicit_in_search = search.topic_specs.iter().any(|s| &s.id == topic_id); |
| 617 | Ok(SearchMatch { |
| 618 | sort_key: SortKey( |
| 619 | Kind::Topic, |
| 620 | !explicit_in_search && &search_string != normalized, |
| 621 | display_string, |
| 622 | topic_id.to_owned(), |
| 623 | ), |
| 624 | kind: Kind::Topic, |
| 625 | object: self, |
| 626 | }) |
| 627 | } |
| 628 | } |
| 629 | } |
| 630 | } |
| 631 | |
| 632 | #[derive(Debug)] |
no test coverage detected