MCPcopy Create free account
hub / github.com/emwalker/digraph / to_search_match

Method to_search_match

backend/src/git/ext.rs:597–629  ·  view source on GitHub ↗
(self, locale: Locale, search: &Search)

Source from the content-addressed store, hash-verified

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)]

Callers 2

into_matchesMethod · 0.80
childrenMethod · 0.80

Calls 5

parseFunction · 0.85
SortKeyClass · 0.85
display_stringMethod · 0.80
idMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected