title: How to declare a generic type that is a raw pointer?
body: <p>Given a struct that wraps a pointer,</p>
  
  <pre><code>pub struct Ptr&lt;T&gt; {
      ptr: T
  }
  </code></pre>
  
  <p>Is it possible to declare that <code>T</code> must be a raw pointer type? eg <code>*mut SomeStruct</code> or <code>*const SomeStruct</code>.</p>
  
  <p>Without this, I'm unable to perform operations like <code>&amp;*self.ptr</code> within a method, since Rust doesn't know <code>ptr</code> can be treated like a pointer.</p>
  
  <hr>
  
  <p>Note that this can be made to work:</p>
  
  <pre><code>pub struct Ptr&lt;T&gt; {
      ptr: *mut T
  }
  </code></pre>
  
  <p>But in that case, it hard-codes <code>*mut</code>, where we might want <code>*const</code> in other cases.</p>
  
  <p>See: <a href="https://stackoverflow.com/a/40303713/432509">this answer</a> to give some context.</p>