dtr_to_rust 0.2.4 → 0.2.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d438e4b50824b1f820f329c291d88bf97034fef9bdfd05b88b5b5a610fa23ee5
4
- data.tar.gz: 581033f850771cfe5165ebb2028973048ddd5d17123690a06b6c4ab99fd30230
3
+ metadata.gz: b65d1e7c39791951dc4d806995143fd2df7e819680f865afcda770031b9315a6
4
+ data.tar.gz: 44526fcab24e6c2d2a1daae54321d962b3d99281f076d670288d2adfe5065534
5
5
  SHA512:
6
- metadata.gz: 07a1b2d9dc755146b4b5cba34c57c7758dbd406b37f8731962aaeb231d92803ec8afe4cc45d6b2da40f3bf30a9741b45ba2b2c5f004736731cf9aff7afeacf57
7
- data.tar.gz: bb416781d416dd6a5cf6901d8264ea28f58fc10fdd9e128c5deed8730c507cf1652a7cd00c13ad23556f2a0326567c834ff06f84fc20dfbcfa341c3674b92122
6
+ metadata.gz: a2f2abf2a127d62c46b880774f49eeccf94dcbfd9ceda0f1e07698d046b843a51209bbac35f8924bea0b66bf31b88788076927686f6ec8e800d13a73f329e3ab
7
+ data.tar.gz: a9eb2c7dc8e95b98aa3fae998c59fe90199166c0e2a7b3ee8edfc4fbc5ddd55c03b90ade0a43abb1b89834127f68e0278f27a08fe92d407f05bc81b758299cc1
data/lib/generator.rb CHANGED
@@ -94,6 +94,10 @@ module DTRToRust
94
94
  case type
95
95
  when 'String'
96
96
  'Symbol'
97
+ when 'Vec<String>'
98
+ 'Vec<Symbol>'
99
+ when 'List<String>'
100
+ 'Vec<Symbol>'
97
101
  else
98
102
  type
99
103
  end
@@ -5,9 +5,27 @@ module DTRToRust
5
5
  # This class is responsible for generating Rust code for the AddAndAssign instruction.
6
6
  class CreateList < Handler
7
7
  def handle
8
- form_rust_string("let #{@instruction[:assign]} = vec![#{@instruction[:inputs].join(', ')}];",
8
+ form_rust_string("let #{@instruction[:assign]} = vec![#{handle_inputs}];",
9
9
  @instruction[:scope])
10
10
  end
11
+
12
+ private
13
+
14
+ def handle_inputs
15
+ @instruction[:inputs].map { |input| handle_input(input) }.join(', ')
16
+ end
17
+
18
+ def handle_input(input)
19
+ decorated_input = Common::InputInterpreter.interpret(input)
20
+
21
+ if decorated_input[:type] == 'string'
22
+ "symbol_short!(#{input})"
23
+ elsif decorated_input[:needs_reference]
24
+ "&#{input}"
25
+ else
26
+ input
27
+ end
28
+ end
11
29
  end
12
30
  end
13
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dtr_to_rust
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Durst