dtr_to_rust 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/generator.rb +12 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d126c4c538c35083034a022b0d7ea4c6848f26e149ad7f1a876912ffce48bb48
|
4
|
+
data.tar.gz: c8ea863fc9d0023717a710ce124c40d384d0be01042c0de6d022c54ee292b52d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68f43f0078b25a6b96ae02fd87d21f7102af319d4dc32ffcdd1e8551d7bea94723fdd8a6bfeb9c2b11203b498573656606b913a17d4995fa805908534fa4310a
|
7
|
+
data.tar.gz: ed189b4cc25fe407de644891b11610d90ebc87e16f9a92b51dcc116c626cc8767357a3494311092d1b1d62a568f03e5075eb23a64408f2c014b97a399a66f0f1
|
data/lib/generator.rb
CHANGED
@@ -60,13 +60,24 @@ module DTRToRust
|
|
60
60
|
def generate_functions_each(functions)
|
61
61
|
functions&.map do |function|
|
62
62
|
return_string = "\n pub fn #{function.name}(#{generate_function_args(function)}) "
|
63
|
-
return_string +=
|
63
|
+
return_string += generate_function_output(function)
|
64
64
|
return_string += " {\n#{generate_instructions_each(function.instructions)}\n }\n"
|
65
65
|
|
66
66
|
return_string
|
67
67
|
end&.join("\n")
|
68
68
|
end
|
69
69
|
|
70
|
+
def generate_function_output(function)
|
71
|
+
return '' if function.output.nil?
|
72
|
+
|
73
|
+
case function.output
|
74
|
+
when 'String'
|
75
|
+
"-> Symbol"
|
76
|
+
else
|
77
|
+
"-> #{function.output}"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
70
81
|
def generate_function_args(function)
|
71
82
|
all_inputs = [] + function.inputs
|
72
83
|
|