Skip to content

bindgen! takes anonymous map parameters by value with borrowed contents #14831

Open

Description

@jrandolf

For an exported function taking an anonymous map, e.g. f: func(m: map<string, list<string>>), bindgen! generates:

pub fn call_f<S: AsContextMut>(&self, store: S, arg0: HashMap<&str, &[String]>) -> ...

while for a named type named = map<string, string> it generates call_g(.., arg0: &Named).

The anonymous form means a caller holding a HashMap<String, Vec<String>> has to build (and hash) a second map of references just to make the call, and it's inconsistent with both named maps and lists (which are &[T]). Generating &HashMap<K, V> with owned keys and values, the way lists are handled, would fix both. Since this changes generated signatures it seems worth settling before map is enabled by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions