Skip to content

Commit c75a7f5

Browse files
committed
chore: Removed unwrap custom functions in favor of From trait
1 parent 1efbebe commit c75a7f5

3 files changed

Lines changed: 12 additions & 8 deletions

File tree

rusty_basic/src/instruction_generator/instruction_generator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use rusty_parser::{BuiltInFunction, UserDefinedTypes};
1515
use rusty_variant::Variant;
1616

1717
pub fn unwrap_linter_context(linter_context: Context) -> (Names, UserDefinedTypes) {
18-
let (pre_linter_result, _, linter_names) = linter_context.unwrap();
19-
let (_, _, user_defined_types) = pre_linter_result.unwrap();
18+
let (pre_linter_result, linter_names) = linter_context.into();
19+
let user_defined_types = pre_linter_result.into();
2020
(linter_names, user_defined_types)
2121
}
2222

rusty_linter/src/converter/common/context.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ impl Context {
4343
}
4444
}
4545

46-
pub fn unwrap(self) -> (PreLinterResult, TypeResolverImpl, Names) {
47-
(self.pre_linter_result, self.resolver, self.names)
48-
}
49-
5046
pub fn is_in_subprogram(&self) -> bool {
5147
self.names.is_in_subprogram()
5248
}
@@ -59,3 +55,9 @@ impl Context {
5955
.and_then(|function_signature_pos| function_signature_pos.element.qualifier())
6056
}
6157
}
58+
59+
impl From<Context> for (PreLinterResult, Names) {
60+
fn from(value: Context) -> Self {
61+
(value.pre_linter_result, value.names)
62+
}
63+
}

rusty_linter/src/pre_linter/pre_linter_result.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ impl PreLinterResult {
2424
user_defined_types,
2525
}
2626
}
27+
}
2728

28-
pub fn unwrap(self) -> (SignatureMap, SignatureMap, UserDefinedTypes) {
29-
(self.functions, self.subs, self.user_defined_types)
29+
impl From<PreLinterResult> for UserDefinedTypes {
30+
fn from(value: PreLinterResult) -> Self {
31+
value.user_defined_types
3032
}
3133
}
3234

0 commit comments

Comments
 (0)