title: unconstrained type parameter error
body: <p>I'm trying to interface glium with cgmath. Following <a href="https://stackoverflow.com/a/40028032/5397009">this answer</a>, I have implemented a <code>ToArray</code> trait to convert instances of <code>cgmath::Matrix4</code> into a format usable by glium:</p>
  
  <pre><code>pub trait ToArray {
      type Output;
      fn to_array(&amp;self) -&gt; Self::Output;
  }
  
  impl&lt;S: cgmath::BaseNum&gt; ToArray for cgmath::Matrix4&lt;S&gt; {
      type Output = [[S; 4]; 4];
      fn to_array(&amp;self) -&gt; Self::Output {
          (*self).into()
      }
  }
  </code></pre>
  
  <p>Since I don't always use <code>Matrix4</code> directly, I need a similar implementation for cgmath transform types. For example for <code>cgmath::Decomposed</code>:</p>
  
  <pre><code>impl&lt;S: cgmath::BaseFloat, R: cgmath::Rotation3&lt;S&gt;&gt; ToArray
      for cgmath::Decomposed&lt;cgmath::Vector3&lt;S&gt;, R&gt; {
      type Output = [[S; 4]; 4];
      fn to_array(&amp;self) -&gt; Self::Output {
          cgmath::Matrix4::&lt;S&gt;::from(*self).into()
      }
  }
  </code></pre>
  
  <p>This works, but I'd like to avoid duplicating the code for all transform types, so I thought I would define a generic implementation for anything that can be converted to a <code>Matrix4</code>:</p>
  
  <pre><code>impl&lt;S: cgmath::BaseFloat, T: Into&lt;cgmath::Matrix4&lt;S&gt;&gt;&gt; ToArray for T {
      type Output = [[S; 4]; 4];
      fn to_array(&amp;self) -&gt; Self::Output {
          cgmath::Matrix4::&lt;S&gt;::from(*self).into()
      }
  }
  </code></pre>
  
  <p>Unfortunately, this doesn't work: </p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0207]: the type parameter `S` is not constrained by the impl trait, self type, or predicates
    --&gt; src/main.rs:23:6
     |
  23 | impl&lt;S: cgmath::BaseFloat, T: Into&lt;cgmath::Matrix4&lt;S&gt;&gt;&gt; ToArray for T {
     |      ^ unconstrained type parameter
  </code></pre>
  
  <p>I have two questions:</p>
  
  <ul>
  <li>Why doesn't the above code work? From reading the <code>rustc --explain</code> output, I would expect the <code>T: Into&lt;cgmath::Matrix4&lt;S&gt;&gt;</code> to act as a valid constraint on <code>S</code> as well as <code>T</code>.</li>
  <li>How can I write a generic implementation for anything that can be converted into a <code>Matrix4</code>?</li>
  </ul>