Skip to content

Commit 1ec67e2

Browse files
committed
fixing warning
1 parent 425c966 commit 1ec67e2

File tree

1 file changed

+11
-25
lines changed

1 file changed

+11
-25
lines changed

microBioRust/src/record.rs

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
///Shared generic record types to reduce duplication between gbk and embl
22
///Minimal initial introduction: defines generic containers and builders that mirror the existing API where possible
3+
34
use std::collections::{HashMap, HashSet};
45

56
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
@@ -21,15 +22,9 @@ impl RangeValue {
2122

2223
///Traits to unify attribute enums across formats. Existing enums can implement Into these trait views if needed
2324
pub trait HasStartStopStrand {
24-
fn start(&self) -> Option<RangeValue> {
25-
None
26-
}
27-
fn stop(&self) -> Option<RangeValue> {
28-
None
29-
}
30-
fn strand(&self) -> Option<i8> {
31-
None
32-
}
25+
fn start(&self) -> Option<RangeValue> { None }
26+
fn stop(&self) -> Option<RangeValue> { None }
27+
fn strand(&self) -> Option<i8> { None }
3328
}
3429

3530
///Generic attribute builders
@@ -44,18 +39,12 @@ where
4439
K: Eq + std::hash::Hash,
4540
V: Eq + std::hash::Hash,
4641
{
47-
pub fn set_name(&mut self, name: String) {
48-
self.name = Some(name);
49-
}
50-
pub fn get_name(&self) -> Option<&String> {
51-
self.name.as_ref()
52-
}
42+
pub fn set_name(&mut self, name: String) { self.name = Some(name); }
43+
pub fn get_name(&self) -> Option<&String> { self.name.as_ref() }
5344
pub fn add(&mut self, key: K, value: V) {
54-
self.attributes.entry(key).or_default().insert(value);
55-
}
56-
pub fn get(&self, key: &K) -> Option<&HashSet<V>> {
57-
self.attributes.get(key)
45+
self.attributes.entry(key).or_insert_with(HashSet::new).insert(value);
5846
}
47+
pub fn get(&self, key: &K) -> Option<&HashSet<V>> { self.attributes.get(key) }
5948
}
6049

6150
///Generic record and records container
@@ -73,17 +62,14 @@ pub struct GenericRecord<S, F, Q> {
7362
}
7463

7564
impl<S, F, Q> GenericRecord<S, F, Q> {
76-
pub fn is_empty(&self) -> bool {
77-
self.id.is_empty() && self.seq.is_empty()
78-
}
65+
pub fn is_empty(&self) -> bool { self.id.is_empty() && self.seq.is_empty() }
7966
}
8067

68+
#[allow(dead_code)]
8169
pub struct GenericRecords<R> {
8270
inner: R,
8371
}
8472

8573
impl<R> GenericRecords<R> {
86-
pub fn new(reader: R) -> Self {
87-
Self { inner: reader }
88-
}
74+
pub fn new(reader: R) -> Self { Self { inner: reader } }
8975
}

0 commit comments

Comments
 (0)