title: How can I have an array of Any type?
body: <p>I'm trying to model a dataframe-like structure. I know how use <code>enum</code>s here, but I'm exploring how do it similar to C#/Python/etc.</p>
  
  <p>I tried to follow <a href="https://stackoverflow.com/questions/41604107/rust-trait-object-conversion">Rust Trait object conversion</a> but things are not working:</p>
  
  <pre><code>use std::any::{Any};
  use std::fmt::Debug;
  
  pub trait Value: Any + Sized {
      fn as_any(&amp;self) -&gt; &amp;Any {
          self
      }
  
      fn as_any_mut(&amp;mut self) -&gt; &amp;mut Any {
          self
      }
  }
  
  impl Value for i32 {}
  
  #[derive(Debug)]
  struct Frame {
      data: Vec&lt;Box&lt;Any&gt;&gt;,
  }
  
  fn make_int(of: Vec&lt;i32&gt;) -&gt; Frame {
      let data = of.into_iter().map(|x| Box::new(x.as_any())).collect();
      Frame {
          data: data,
      }
  }
  </code></pre>
  
  <p>The compiler complains:</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0277]: the trait bound `std::vec::Vec&lt;std::boxed::Box&lt;std::any::Any&gt;&gt;: std::iter::FromIterator&lt;std::boxed::Box&lt;&amp;std::any::Any&gt;&gt;` is not satisfied
    --&gt; src/main.rs:40:61
     |
  40 |     let data = of.into_iter().map(|x| Box::new(x.as_any())).collect();
     |                                                             ^^^^^^^ a collection of type `std::vec::Vec&lt;std::boxed::Box&lt;std::any::Any&gt;&gt;` cannot be built from an iterator over elements of type `std::boxed::Box&lt;&amp;std::any::Any&gt;`
     |
     = help: the trait `std::iter::FromIterator&lt;std::boxed::Box&lt;&amp;std::any::Any&gt;&gt;` is not implemented for `std::vec::Vec&lt;std::boxed::Box&lt;std::any::Any&gt;&gt;`
  </code></pre>