title: How can I invoke an unknown Rust function with some arguments using reflection?
body: <p>I'm having a lot of fun playing around with Rust having been a C# programmer for a long time but I have a question around reflection. Maybe I don't need reflection in this case but given that Rust is strongly typed I suspect I do (I would definitely need it in good ol' C#, bless its cotton socks).</p>
  
  <p>I have this situation:</p>
  
  <pre><code>use std::collections::HashMap;
  
  fn invoke_an_unknown_function(
      hashmap: HashMap&lt;String, String&gt;,
      // Something to denote a function I know nothing about goes here
  ) {
      // For each key in the hash map, assign the value
      // to the parameter argument whose name is the key
      // and then invoke the function
  }
  </code></pre>
  
  <p>How would I do that? I'm guessing I need to pass in some sort of <code>MethodInfo</code> as the second argument to the function and then poke around with that to get the arguments whose name is the key in the hash map and assign the values but I had a look around for the reflection API and found the following pre-Rust 1.0 documentation:</p>
  
  <ul>
  <li><a href="http://static.rust-lang.org/doc/0.8/std/reflect/index.html" rel="nofollow noreferrer">Module <code>std::reflect</code></a></li>
  <li><a href="http://static.rust-lang.org/doc/0.8/std/repr/index.html" rel="nofollow noreferrer">Module <code>std::repr</code></a></li>
  <li><a href="https://mail.mozilla.org/pipermail/rust-dev/2012-July/002064.html" rel="nofollow noreferrer">[rust-dev] Reflection system</a></li>
  </ul>
  
  <p>None of these give me enough to go on to get started.  How would I implement the function I describe above?</p>