Using generic trait methods like .into() when type inference is impossible
<p>I'm hoping to be able to use <code>.into()</code> to convert a value in a context where type inference is impossible. This is typically when I want to convert a temporary value into some other type for passing it into a generic function. See the following code for an example (<a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=9bf3ac22e1fbb5122ad30499d3e5070c" rel="noreferrer">playground</a>):</p>

<pre><code>use std::convert::*;

struct NewType(pub i32);

impl From&lt;NewType&gt; for i32 {
    fn from(src: NewType) -&gt; i32 {
        src.0
    }
}

fn main() {
    let a = NewType(5);
    println!("{}", a.into()); // Understandably won't compile
}
</code></pre>

<p>I get the error:</p>

<pre class="lang-none prettyprint-override"><code>error[E0282]: type annotations needed
  --&gt; src/main.rs:13:20
   |
13 |     println!("{}", a.into());
   |                    ^^^^^^^^ cannot infer type for `T`
</code></pre>

<p>How do I properly tell the compiler that I want to convert <code>a</code> into <code>i32</code>?</p>

<p>I can get it to work right by explicitly feeding <code>Into</code> with type arguments: <code>Into::&lt;i32&gt;::into(a)</code>. This is more verbose and explicit than I was hoping to be able to achieve, especially in a context where I have not imported <code>Into</code> (<code>std::convert::Into::&lt;i32&gt;::into(a)</code>). <code>a.into::&lt;i32&gt;()</code> would be acceptable, but that is not where the type arguments go.</p>

<p><code>a.into() as i32</code> would look nice, but this exact syntax doesn't work.</p>

<p>Is there a trick I am missing?</p>