title: What is the overhead of Rust's Option type?
body: <p>In Rust, references can never be null, so in case where you actually need null, such as a linked list, you use the <code>Option</code> type:</p>
  
  <pre><code>struct Element {
      value: i32,
      next: Option&lt;Box&lt;Element&gt;&gt;,
  }
  </code></pre>
  
  <p>How much overhead is involved in this in terms of memory allocation and steps to dereference compared to a simple pointer? Is there some "magic" in the compiler/runtime to make <code>Option</code> cost-free, or less costly than if one were to implement <code>Option</code> by oneself in a non-core library using the same <code>enum</code> construct, or by wrapping the pointer in a vector?</p>