Closed stuxnot closed 2 weeks ago
The downside of having to specify the type of the empty map could also be removed by having an additional function which has no labels argument, since the caller already knows that he will not need labels if he specified an empty map.
When implementing a small cli program using the rust bindings, I noticed that the generics in the
assemble
functions force the caller to create aHashMap<&str, u64>
, which is only possible when also owning an additional container holding theString
s of the labels. When dynamically creating the labels, this forces the caller to have an additional container holding the actualString
s.My proposal is changing the generics of the
assemble
functions to takeAsRef<str>
instead of&str
. This way bothMap<&str, _>
and&Map<String, _>
could be passed to the functions. The only downside to this change would be that rust will be unable to infer the type of an empty map, forcing the caller to specify the type of the map explicitly: