title: How to use numeric values as generics paramters in Rust?
body: <p>I am learning Rust as a beginner.
  I'm curious about how can we use numeric values as generics parameters that will be compiled at compile-time similar to template in C++</p>
  
  <p>This is an equivalent C++ code.</p>
  
  <pre class="lang-cpp prettyprint-override"><code>template&lt;class T, int dim&gt;
  struct vec {
      std::array&lt;T, dim&gt; data;
      vec(): data() {}
      vec(const vec&lt;T, dim&gt;&amp; obj): data(obj.data) {}
      ~vec() {}
  };
  int main() {
      vec&lt;float, 3&gt; v3;
  }
  </code></pre>
  
  <p>That code above will be compiled the same as</p>
  
  <pre class="lang-cpp prettyprint-override"><code>struct vec {
      std::array&lt;float, 3&gt; data;
      vec(): data() {}
      vec(const vec&lt;float, 3&gt;&amp; obj): data(obj.data) {}
      ~vec() {}
  };
  int main() {
      vec v3;
  }
  </code></pre>