title: Getting to know Rust and the type system
body: <p>Coming from the ML family and learned to program in SML, a very strict type system are common place.</p>
  <p>I'm trying to learn Rust, and since I'm used to strongly typed languages an being a computer science student which are majoring in compiler theory and programming language theory. I thought that I just skipped those boring hello world intro things. I'm trying to get to know the type system with generics and lifetime in my scope at the moment.</p>
  <p>For a simple project I'm implementing a single linked list library since I miss it and it will give me a feeling of how the type system works. I'm using reference/borrowing instead of boxing to keep thing on the stack, hence need to explicitly tell the compiler when a list node goes out of scope.</p>
  <pre><code>pub enum List&lt;'a, L&gt; {
      Cons(L,  &amp;'a List&lt;'a, L&gt;),
      Nil,
  }
  
  impl&lt;'a, L, S&gt; List&lt;'a, L&gt; {
  //          ^ unconstrained type parameter // error here
      pub fn new() -&gt; List&lt;'a,L&gt; { 
          &amp;List::Nil 
      }
  
      pub fn fold(f : fn(S, L) -&gt; S, acc : S, lst : List&lt;'a,L&gt;) -&gt; S {
          match lst {
              List::Cons(item, rest) =&gt; fold(f, f(acc,item), rest),
              List::Nil =&gt; acc,
          }
      }
  }
  </code></pre>
  <p>I get that the type parameter S are unconstraint, why does it need to be, when I clearly don't want it to be constraint at all? Coming from SML and F# where this is no problem, since this can be deduced at compile time.</p>
  <p>I know that tail recursion elimination are yet to become a feature of Rust, this is not the subject of this question.</p>