Skip to content

Commit

Permalink
Some fixes for Rust code generation (#495)
Browse files Browse the repository at this point in the history
  • Loading branch information
travis79 authored Jun 10, 2022
1 parent bddb15a commit d4b2164
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion glean_parser/rust.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def output_rust(
template.render(
parser_version=__version__,
categories=categories,
extra_args=util.metric_args,
extra_metric_args=util.extra_metric_args,
common_metric_args=util.common_metric_args,
)
)
6 changes: 3 additions & 3 deletions glean_parser/templates/rust.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ pub struct {{ obj.name|Camelize }}{{ suffix }} {
impl ExtraKeys for {{ obj.name|Camelize }}{{ suffix }} {
const ALLOWED_KEYS: &'static [&'static str] = {{ obj.allowed_extra_keys|extra_keys }};

fn into_ffi_extra(self) -> ::std::collections::HashMap<String, String> {
fn into_ffi_extra(self) -> ::std::collections::HashMap<::std::string::String, ::std::string::String> {
let mut map = ::std::collections::HashMap::new();
{% for key, _ in obj|attr(name) %}
self.{{key|snake_case}}.and_then(|val| map.insert("{{key}}", val));
self.{{key|snake_case}}.and_then(|val| map.insert("{{key}}".to_string(), val));
{% endfor %}
map
}
Expand Down Expand Up @@ -72,7 +72,7 @@ pub mod {{ category.name|snake_case }} {
disabled: {{ obj.is_disabled()|rust }},
..Default::default()
}
{%- for arg_name in extra_args if obj[arg_name] is defined and arg_name not in common_metric_args and arg_name != 'allowed_extra_keys' -%}
{%- for arg_name in extra_metric_args if obj[arg_name] is defined and arg_name != 'allowed_extra_keys' -%}
, {{ obj[arg_name]|rust }}
{%- endfor -%}
{{ ", " if obj.labeled else ")\n" }}
Expand Down

0 comments on commit d4b2164

Please sign in to comment.