Skip to content

Commit 9508db6

Browse files
authored
Merge pull request #1014 from schungx/master
Fix type parsing.
2 parents 70e332e + e881ec4 commit 9508db6

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

src/api/definitions/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,11 +491,11 @@ impl FuncMetadata {
491491
first = false;
492492

493493
let (param_name, param_type) = self.params_info.get(i).map_or(("_", "?".into()), |s| {
494-
let (name, typ) = s.split_once(':').unwrap_or((s.trim(), "?"));
494+
let (name, typ) = s.split_once(':').unwrap_or((s, ""));
495495
(
496496
name.trim().split(' ').last().unwrap().trim(),
497497
match typ.trim() {
498-
"" | "?" => "?".into(),
498+
"" | "?" | "_" => "?".into(),
499499
typ => def_type_name(typ, def.engine),
500500
},
501501
)

src/module/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,13 @@ impl FuncMetadata {
125125
.params_info
126126
.iter()
127127
.map(|param| {
128-
let (name, typ) = param.split_once(':').unwrap();
128+
let (name, typ) = param.split_once(':').unwrap_or((param, ""));
129129
let name = match name.trim() {
130-
"" => "_",
130+
"" | "?" | "_" => "_",
131131
s => s,
132132
};
133133
match typ.trim() {
134-
"" => name.into(),
134+
"" | "?" | "_" => name.into(),
135135
typ => format!(
136136
"{name}: {}",
137137
format_param_type_for_display(&type_mapper(typ), false)

src/serde/metadata.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,16 @@ impl<'a> From<(&'a RhaiFunc, &'a FuncMetadata)> for FnMetadata<'a> {
145145
.params_info
146146
.iter()
147147
.map(|s| {
148-
let (name, typ) = s.split_once(':').unwrap();
148+
let (name, typ) = s.split_once(':').unwrap_or((s.trim(), ""));
149149
FnParam {
150-
name: (name.trim() != "_").then_some(name),
151-
typ: (!typ.trim().is_empty())
152-
.then(|| format_param_type_for_display(typ, false)),
150+
name: match name.trim() {
151+
"" | "?" | "_" => None,
152+
s => Some(s),
153+
},
154+
typ: match typ.trim() {
155+
"" | "?" | "_" => None,
156+
typ => Some(format_param_type_for_display(typ, false).into()),
157+
},
153158
}
154159
})
155160
.collect(),

0 commit comments

Comments
 (0)