title: Does Rust have an equivalent to C++'s decltype() to get the type of an expression?
body: <p>My code looks like:</p>
  <pre class="lang-rust prettyprint-override"><code>macro_rules! mask {
      ($bitmap: tt, [..$count: tt], for type = $ty: ty) =&gt; {
          {
              let bit_count = std::mem::size_of::&lt;$ty&gt;() * 8;
              let dec_bit_count = bit_count - 1;
              $bitmap &amp; [(1 &lt;&lt; ($count &amp; dec_bit_count)) - 1, &lt;$ty&gt;::MAX][((($count &amp; !dec_bit_count)) != 0) as usize]
          }
      };
  }
  
  fn main() {
      let bitmap: u8 = 0b_1111_1111;
      let masked_bitmap = mask!(bitmap, [..5], for type = u8);
      println!(&quot;{:#010b}&quot;, masked_bitmap);
  }
  </code></pre>
  <p>The above code will mask the bitmap. In the above example, <code>0b_1111_1111</code> on being masked by <code>[..5]</code> will become <code>0b_0001_1111</code>.</p>
  <p>I want my macro to be like this:</p>
  <pre class="lang-rust prettyprint-override"><code>macro_rules! mask {
      ($bitmap: tt, [..$count: tt]) =&gt; {
          {
              let bit_count = std::mem::size_of::&lt;decltype($bitmap)&gt;() * 8;
              let dec_bit_count = bit_count - 1;
              $bitmap &amp; [(1 &lt;&lt; ($count &amp; dec_bit_count)) - 1, &lt;decltype($bitmap)&gt;::MAX][((($count &amp; !dec_bit_count)) != 0) as usize]
          }
      };
  }
  </code></pre>
  <p>But I have to pass type to the macro to get this done. Is there something like <code>decltype()</code> from C++ that I could use?</p>