title: generic callback with data
body: <p>There is already a very <a href="https://stackoverflow.com/questions/41081240/idiomatic-callbacks-in-rust">popular question</a> about this topic but I don;t fully understand the answer.</p>
  <p>The goal is:</p>
  <p>I need a list (read a Vec) of &quot;function pointers&quot; that modify data stored elsewhere in a program. The simplest example I can come up with are callbacks to be called when a key is pressed. So when any key is pressed, all functions passed to the object will be called in some order.</p>
  <p>Reading the answer, it is not clear to me how I would be able to make such a list. It sounds like I would need to restrict the type of the callback to something known, else I don't know how you would be able to make an array of it.</p>
  <p>It's also not clear to me how to store the data pointers/references.</p>
  <p>Say I have</p>
  <pre class="lang-rust prettyprint-override"><code>struct Processor&lt;CB&gt;
  where
      CB: FnMut(),
  {
      callback: CB,
  }
  </code></pre>
  <p>Like the answer suggests, I can't make an array of processors, can I? since each Processor is technically a different type depending on the generic isntantiation.</p>