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

Function append_synonym

backend/src/git/topic.rs:19–59  ·  view source on GitHub ↗
(
    mut repo_topic: RepoTopic,
    name: &str,
    locale: Locale,
    date: Timestamp,
)

Source from the content-addressed store, hash-verified

17}
18
19fn append_synonym(
20 mut repo_topic: RepoTopic,
21 name: &str,
22 locale: Locale,
23 date: Timestamp,
24) -> RepoTopic {
25 let mut synonyms = vec![Synonym {
26 name: name.to_owned(),
27 added: date,
28 locale: Locale::EN,
29 }];
30
31 match &mut repo_topic.metadata.details {
32 Some(details) => {
33 let mut seen: HashSet<(String, Locale)> = HashSet::new();
34 seen.insert((name.to_owned(), locale));
35
36 for synonym in &details.synonyms {
37 let key = (synonym.name.to_owned(), synonym.locale);
38 if seen.contains(&key) {
39 continue;
40 }
41
42 seen.insert(key);
43 synonyms.push(synonym.to_owned());
44 }
45
46 details.synonyms = synonyms;
47 }
48
49 None => {
50 repo_topic.metadata.details = Some(RepoTopicDetails {
51 root: false,
52 synonyms,
53 timerange: None,
54 });
55 }
56 }
57
58 repo_topic
59}
60
61pub struct DeleteTopic {
62 pub actor: Arc<Viewer>,

Callers 1

update_repo_topicMethod · 0.85

Calls 2

insertMethod · 0.80
containsMethod · 0.80

Tested by

no test coverage detected