Skip to content

Commit 9c2e68e

Browse files
committed
chore: Change ConstantMap type into a struct for encapsulation
1 parent c75a7f5 commit 9c2e68e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

rusty_linter/src/pre_linter/constant_map.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ use rusty_variant::Variant;
66

77
use crate::core::*;
88

9-
pub type ConstantMap = HashMap<BareName, Variant>;
9+
#[derive(Default)]
10+
pub struct ConstantMap(HashMap<BareName, Variant>);
1011

1112
impl ConstLookup for ConstantMap {
1213
fn get_resolved_constant(&self, name: &CaseInsensitiveString) -> Option<&Variant> {
13-
self.get(name)
14+
self.0.get(name)
1415
}
1516
}
1617

@@ -20,7 +21,7 @@ impl Visitor<Constant> for ConstantMap {
2021
let (name_pos, expression_pos) = element.into();
2122
let Positioned { element: name, pos } = name_pos;
2223
let bare_name: &BareName = name.bare_name();
23-
(match self.get(bare_name) {
24+
(match self.0.get(bare_name) {
2425
Some(_) => Err(LintError::DuplicateDefinition.at(pos)),
2526
_ => Ok(()),
2627
})
@@ -30,7 +31,7 @@ impl Visitor<Constant> for ConstantMap {
3031
Name::Qualified(_, qualifier) => v.cast(*qualifier).map_err(|e| e.at(expression_pos)),
3132
})
3233
.map(|casted| {
33-
self.insert(bare_name.clone(), casted);
34+
self.0.insert(bare_name.clone(), casted);
3435
})
3536
}
3637
}

0 commit comments

Comments
 (0)