× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Unresolved import from_str

Chris Morgan
Jul 15, 2015
<p><a href="http://doc.rust-lang.org/std/index.html?search=from_str">Use the docs to search for <code>from_str</code>.</a> They show that the <code>FromStr</code> trait is in <code>std::str</code> now, not <code>std::from_str</code>. (April 2014 is a <em>long</em> time ago in Rust terms, being well before Rust 1.0.0.)</p> <p><code>FromStr</code> should not be used directly in general anyway; you should use <a href="http://doc.rust-lang.org/std/primitive.str.html#method.parse"><code>str.parse</code> method</a> instead: <code>my_str.parse::&lt;u32&gt;()</code>. Remember that it returns a <code>Result</code>, because the string might just not contain a number.</p> <p>This tip was originally posted on <a href="http://stackoverflow.com/questions/31330767/Unresolved%20import%20from_str/31330882">Stack Overflow</a>.</p>
comments powered by Disqus