Skip to content

Commit d0b1831

Browse files
committed
Fix clippy issues, especially now needless conversions with .into()
1 parent 926ff95 commit d0b1831

10 files changed

Lines changed: 56 additions & 64 deletions

File tree

core/src/annostorage/inmemory.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ where
297297
result = self
298298
.anno_values
299299
.get_value_ref(old_value)
300-
.map(|v| Cow::Owned(v.clone().into()));
300+
.map(|v| Cow::Owned(v.clone()));
301301

302302
self.check_and_remove_value_symbol(old_value);
303303
self.total_number_of_annos -= 1;
@@ -505,7 +505,7 @@ where
505505
ns: String::default(),
506506
}..AnnoKey {
507507
name: name.into(),
508-
ns: std::char::MAX.to_string().into(),
508+
ns: std::char::MAX.to_string(),
509509
},
510510
),
511511
};

core/src/annostorage/ondisk.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ where
366366
let already_existed =
367367
item_smaller_than_largest && self.by_container.contains_key(&by_container_key)?;
368368
self.by_container
369-
.insert(by_container_key, anno.val.clone().into())?;
369+
.insert(by_container_key, anno.val.clone())?;
370370

371371
// To save some space, insert an boolean value as a marker value
372372
// (all information is part of the key already)
@@ -401,7 +401,7 @@ where
401401
let parsed_key = self.parse_by_container_key(key)?;
402402
let anno = Annotation {
403403
key: parsed_key.1.as_ref().clone(),
404-
val: val.into(),
404+
val,
405405
};
406406
result.push(anno);
407407
}
@@ -429,7 +429,7 @@ where
429429
// remove annotation from by_anno_qname
430430
let anno = Annotation {
431431
key: key.as_ref().clone(),
432-
val: val.into(),
432+
val,
433433
};
434434

435435
self.by_anno_qname.remove(&create_by_anno_qname_key(
@@ -472,7 +472,7 @@ where
472472
// remove annotation from by_anno_qname
473473
let anno = Annotation {
474474
key: key.clone(),
475-
val: val.into(),
475+
val,
476476
};
477477

478478
self.by_anno_qname.remove(&create_by_anno_qname_key(
@@ -496,7 +496,7 @@ where
496496
}
497497
}
498498

499-
return Ok(Some(Cow::Owned(anno.val.into())));
499+
return Ok(Some(Cow::Owned(anno.val)));
500500
}
501501
}
502502
Ok(None)
@@ -662,7 +662,7 @@ where
662662
ns: String::default(),
663663
}..AnnoKey {
664664
name: name.into(),
665-
ns: std::char::MAX.to_string().into(),
665+
ns: std::char::MAX.to_string(),
666666
},
667667
),
668668
};

core/src/graph/serialization/graphml.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,8 @@ fn add_node(
456456
for (key, value) in data.drain() {
457457
node_updates.add_event(UpdateEvent::AddNodeLabel {
458458
node_name: node_name.clone(),
459-
anno_ns: key.ns.into(),
460-
anno_name: key.name.into(),
459+
anno_ns: key.ns,
460+
anno_name: key.name,
461461
anno_value: value,
462462
})?;
463463
}
@@ -480,21 +480,21 @@ fn add_edge<CT: ComponentType>(
480480
edge_updates.add_event(UpdateEvent::AddEdge {
481481
source_node: source.clone(),
482482
target_node: target.clone(),
483-
layer: component.layer.clone().into(),
483+
layer: component.layer.clone(),
484484
component_type: component.get_type().to_string(),
485-
component_name: component.name.clone().into(),
485+
component_name: component.name.clone(),
486486
})?;
487487

488488
// Add all remaining data entries as annotations
489489
for (key, value) in data.drain() {
490490
edge_updates.add_event(UpdateEvent::AddEdgeLabel {
491491
source_node: source.clone(),
492492
target_node: target.clone(),
493-
layer: component.layer.clone().into(),
493+
layer: component.layer.clone(),
494494
component_type: component.get_type().to_string(),
495-
component_name: component.name.clone().into(),
496-
anno_ns: key.ns.into(),
497-
anno_name: key.name.into(),
495+
component_name: component.name.clone(),
496+
anno_ns: key.ns,
497+
anno_name: key.name,
498498
anno_value: value,
499499
})?;
500500
}

graphannis/src/annis/db/aql/model.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,7 @@ impl ComponentType for AnnotationComponentType {
520520
&& component_name.is_empty()
521521
{
522522
// might be a new text coverage component
523-
let c =
524-
AnnotationComponent::new(ctype.clone(), layer.into(), component_name.into());
523+
let c = AnnotationComponent::new(ctype.clone(), layer, component_name);
525524
index.text_coverage_components.insert(c);
526525
}
527526

@@ -666,7 +665,7 @@ impl ComponentType for AnnotationComponentType {
666665
base_token_count,
667666
segmentation_count: token_count_by_ordering_component
668667
.into_iter()
669-
.map(|(k, v)| (k.name.into(), v))
668+
.map(|(k, v)| (k.name, v))
670669
.collect(),
671670
},
672671
});

graphannis/src/annis/db/aql/operators/near.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl BinaryOperatorSpec for NearSpec {
4747
};
4848
let component_order = Component::new(
4949
AnnotationComponentType::Ordering,
50-
ordering_layer.into(),
50+
ordering_layer,
5151
self.segmentation
5252
.as_ref()
5353
.map_or_else(String::default, |s| s.into()),
@@ -98,8 +98,8 @@ impl<'a> Near<'a> {
9898
};
9999
let component_order = Component::new(
100100
AnnotationComponentType::Ordering,
101-
ordering_layer.into(),
102-
spec.segmentation.clone().unwrap_or_default().into(),
101+
ordering_layer,
102+
spec.segmentation.clone().unwrap_or_default(),
103103
);
104104

105105
let gs_order = graph.get_graphstorage(&component_order).ok_or_else(|| {

graphannis/src/annis/db/aql/operators/precedence.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ impl BinaryOperatorSpec for PrecedenceSpec {
5757
};
5858
let component_order = AnnotationComponent::new(
5959
AnnotationComponentType::Ordering,
60-
ordering_layer.into(),
61-
self.segmentation.clone().unwrap_or_default().into(),
60+
ordering_layer,
61+
self.segmentation.clone().unwrap_or_default(),
6262
);
6363

6464
let mut v = HashSet::default();
@@ -108,8 +108,8 @@ impl<'a> Precedence<'a> {
108108
};
109109
let component_order = AnnotationComponent::new(
110110
AnnotationComponentType::Ordering,
111-
ordering_layer.into(),
112-
spec.segmentation.clone().unwrap_or_default().into(),
111+
ordering_layer,
112+
spec.segmentation.clone().unwrap_or_default(),
113113
);
114114

115115
let gs_order = graph.get_graphstorage(&component_order).ok_or_else(|| {

graphannis/src/annis/db/corpusstorage.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ impl CorpusStorage {
965965
CorpusConfiguration::default()
966966
};
967967

968-
(orig_corpus_name.into(), g, config)
968+
(orig_corpus_name, g, config)
969969
}
970970
};
971971

@@ -979,7 +979,7 @@ impl CorpusStorage {
979979

980980
self.update_corpus_size_info(&mut config, &graph);
981981

982-
let corpus_name = corpus_name.unwrap_or_else(|| orig_name.into());
982+
let corpus_name = corpus_name.unwrap_or(orig_name);
983983
let db_path = self.corpus_directory_on_disk(&corpus_name);
984984

985985
let mut cache_lock = self.corpus_cache.write()?;
@@ -2294,8 +2294,8 @@ impl CorpusStorage {
22942294
annokeys.push((
22952295
node_ref,
22962296
vec![AnnoKey {
2297-
ns: ns.clone().into(),
2298-
name: def.name.clone().into(),
2297+
ns: ns.clone(),
2298+
name: def.name.clone(),
22992299
}],
23002300
));
23012301
} else {

graphannis/src/annis/db/exec/nodesearch.rs

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,12 @@ impl NodeSearchSpec {
122122
| NodeSearchSpec::NotExactTokenValue { .. }
123123
| NodeSearchSpec::RegexTokenValue { .. }
124124
| NodeSearchSpec::NotRegexTokenValue { .. }
125-
| NodeSearchSpec::AnyToken => (
126-
Some(TOKEN_KEY.ns.clone().into()),
127-
Some(TOKEN_KEY.name.clone().into()),
128-
),
125+
| NodeSearchSpec::AnyToken => {
126+
(Some(TOKEN_KEY.ns.clone()), Some(TOKEN_KEY.name.clone()))
127+
}
129128
NodeSearchSpec::AnyNode => (
130-
Some(NODE_TYPE_KEY.ns.clone().into()),
131-
Some(NODE_TYPE_KEY.name.clone().into()),
129+
Some(NODE_TYPE_KEY.ns.clone()),
130+
Some(NODE_TYPE_KEY.name.clone()),
132131
),
133132
}
134133
}
@@ -550,8 +549,8 @@ impl<'a> NodeSearch<'a> {
550549
)),
551550
node_search_desc: Arc::new(NodeSearchDesc {
552551
qname: (
553-
Some(NODE_TYPE_KEY.ns.clone().into()),
554-
Some(NODE_TYPE_KEY.name.clone().into()),
552+
Some(NODE_TYPE_KEY.ns.clone()),
553+
Some(NODE_TYPE_KEY.name.clone()),
555554
),
556555
cond: vec![filter_func],
557556
const_output: Some(NODE_TYPE_KEY.clone()),
@@ -923,10 +922,7 @@ impl<'a> NodeSearch<'a> {
923922
est_output,
924923
)),
925924
node_search_desc: Arc::new(NodeSearchDesc {
926-
qname: (
927-
Some(TOKEN_KEY.ns.clone().into()),
928-
Some(TOKEN_KEY.name.clone().into()),
929-
),
925+
qname: (Some(TOKEN_KEY.ns.clone()), Some(TOKEN_KEY.name.clone())),
930926
cond: filters,
931927
const_output: Some(NODE_TYPE_KEY.clone()),
932928
}),
@@ -981,10 +977,7 @@ impl<'a> NodeSearch<'a> {
981977
est_output,
982978
)),
983979
node_search_desc: Arc::new(NodeSearchDesc {
984-
qname: (
985-
Some(TOKEN_KEY.ns.clone().into()),
986-
Some(TOKEN_KEY.name.clone().into()),
987-
),
980+
qname: (Some(TOKEN_KEY.ns.clone()), Some(TOKEN_KEY.name.clone())),
988981
cond: filters,
989982
const_output: Some(NODE_TYPE_KEY.clone()),
990983
}),

graphannis/src/annis/db/relannis.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,7 @@ where
910910
.or_insert(1);
911911
if *existing_count > 1 {
912912
let old_name = name.clone();
913-
name = format!("{}_duplicated_document_name_{}", name, existing_count).into();
913+
name = format!("{}_duplicated_document_name_{}", name, existing_count);
914914
warn!(
915915
"duplicated document name \"{}\" detected: will be renamed to \"{}\"",
916916
old_name, name
@@ -928,7 +928,7 @@ where
928928
CorpusTableEntry {
929929
pre: pre_order,
930930
post: post_order,
931-
normalized_name: String::from(normalized_name.to_string()),
931+
normalized_name: normalized_name.to_string(),
932932
name,
933933
},
934934
);
@@ -1050,7 +1050,7 @@ where
10501050
.to_string(),
10511051
layer: ordering_layer,
10521052
component_type: AnnotationComponentType::Ordering.to_string(),
1053-
component_name: current_textprop.segmentation.clone().into(),
1053+
component_name: current_textprop.segmentation.clone(),
10541054
})?;
10551055
} // end if same text
10561056

@@ -1181,9 +1181,9 @@ fn add_automatic_cov_edge_for_node(
11811181
.get(&tok_id)?
11821182
.ok_or(RelAnnisError::NodeNotFound(*tok_id))?
11831183
.to_string(),
1184-
layer: component_layer.into(),
1184+
layer: component_layer,
11851185
component_type: AnnotationComponentType::Coverage.to_string(),
1186-
component_name: component_name.into(),
1186+
component_name,
11871187
})?;
11881188
}
11891189
}
@@ -1461,7 +1461,7 @@ where
14611461
node_name: node_path.clone(),
14621462
node_type: "node".to_owned(),
14631463
})?;
1464-
id_to_node_name.insert(node_nr, node_path.clone().into())?;
1464+
id_to_node_name.insert(node_nr, node_path.clone())?;
14651465

14661466
if let Some(layer) = layer
14671467
&& !layer.is_empty()
@@ -1866,9 +1866,9 @@ where
18661866
.get(&target)?
18671867
.ok_or(RelAnnisError::NodeNotFound(target))?
18681868
.to_string(),
1869-
layer: c.layer.clone().into(),
1869+
layer: c.layer.clone(),
18701870
component_type: c.get_type().to_string(),
1871-
component_name: c.name.clone().into(),
1871+
component_name: c.name.clone(),
18721872
})?;
18731873

18741874
let pre: u32 = get_field_not_null(&line, 0, "pre", &rank_tab_path)?.parse()?;
@@ -1957,7 +1957,7 @@ where
19571957
.get(&e.target)?
19581958
.ok_or(RelAnnisError::NodeNotFound(e.target))?
19591959
.to_string(),
1960-
layer: c.layer.clone().into(),
1960+
layer: c.layer.clone(),
19611961
component_type: c.get_type().to_string(),
19621962
component_name: c.name.to_string(),
19631963
anno_ns: ns.to_string(),
@@ -2030,12 +2030,12 @@ fn get_parent_path(cid: u32, corpus_table: &ParsedCorpusTable) -> Result<std::st
20302030
}
20312031

20322032
fn get_corpus_path(cid: u32, corpus_table: &ParsedCorpusTable) -> Result<String> {
2033-
let mut result: String = get_parent_path(cid, corpus_table)?.into();
2033+
let mut result: String = get_parent_path(cid, corpus_table)?;
20342034
let corpus = corpus_table
20352035
.corpus_by_id
20362036
.get(&cid)
20372037
.ok_or(RelAnnisError::CorpusNotFound(cid))?;
2038-
result.push_str("/");
2038+
result.push('/');
20392039
result.push_str(&corpus.normalized_name);
20402040
Ok(result)
20412041
}
@@ -2080,9 +2080,9 @@ fn add_subcorpora(
20802080
for ((entry_cid, anno_key), val) in corpus_id_to_annos.range(start_key..) {
20812081
if entry_cid == cid {
20822082
updates.add_event(UpdateEvent::AddNodeLabel {
2083-
node_name: corpus_table.toplevel_corpus_name.as_str().into(),
2084-
anno_ns: anno_key.ns.clone().into(),
2085-
anno_name: anno_key.name.clone().into(),
2083+
node_name: corpus_table.toplevel_corpus_name.clone(),
2084+
anno_ns: anno_key.ns.clone(),
2085+
anno_name: anno_key.name.clone(),
20862086
anno_value: val.into(),
20872087
})?;
20882088
} else {
@@ -2132,8 +2132,8 @@ fn add_subcorpora(
21322132
if entry_cid == corpus_id {
21332133
updates.add_event(UpdateEvent::AddNodeLabel {
21342134
node_name: subcorpus_full_name.to_string(),
2135-
anno_ns: anno_key.ns.clone().into(),
2136-
anno_name: anno_key.name.clone().into(),
2135+
anno_ns: anno_key.ns.clone(),
2136+
anno_name: anno_key.name.clone(),
21372137
anno_value: val.clone(),
21382138
})?;
21392139
} else {

webservice/src/api/corpora.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ pub async fn list_components(
176176
.into_iter()
177177
.map(|c| Component {
178178
ctype: c.get_type(),
179-
name: c.name.into(),
180-
layer: c.layer.into(),
179+
name: c.name,
180+
layer: c.layer,
181181
})
182182
.collect();
183183

0 commit comments

Comments
 (0)