TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Rust 1.46

391 pointsby pietroalbiniover 4 years ago

12 comments

est31over 4 years ago
The most exciting component of this release is the const fn improvements. With loops and if available, you can now do non-trivial computation in const fn for the first time. It reduces the gap between Rust&#x27;s const fn and C++&#x27;s constexpr to a large degree. Ultimately, the miri execution engine that this feature builds upon, supports a much larger set of features that even constexpr supports. It&#x27;s been a project spanning years to get it merged into the compiler, used for const fn evaluation, and stabilize it&#x27;s features (this part is far from over).<p>In addition to the linked examples, I have some code of my own which is made simpler due to this feature: <a href="https:&#x2F;&#x2F;github.com&#x2F;RustAudio&#x2F;ogg&#x2F;commit&#x2F;b79d65dced32342a5f9313960856114d88d50f4a" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;RustAudio&#x2F;ogg&#x2F;commit&#x2F;b79d65dced32342a5f93...</a><p>Previously, the table was present as an array literal in C-style, now I can remove it once I decide for the library to require the 1.46 compiler or later versions.<p>Link to the old&#x2F;current generation code: <a href="https:&#x2F;&#x2F;github.com&#x2F;RustAudio&#x2F;ogg&#x2F;blob&#x2F;master&#x2F;examples&#x2F;crc32-table-generate.rs" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;RustAudio&#x2F;ogg&#x2F;blob&#x2F;master&#x2F;examples&#x2F;crc32-...</a>
评论 #24300282 未加载
评论 #24295474 未加载
评论 #24295751 未加载
sfvisserover 4 years ago
I’m learning rust right now and there is a lot to like. Steady updates like this are also very motivating. The ecosystem feels very sane - especially compared to npm. Top notch Wasm support, cross compiling is a breeze.<p>That said, coming from a FP background (mostly Haskell&#x2F;JS, now TS) Rust is... hard. I do understand the basic rules of the borrow checker, I do conceptually understand lifetimes, but actually using them is tricky.<p>Especially in a combinator world with lots of higher order functions&#x2F;closures it’s often completely unclear who should own what. It often feels my library&#x2F;dsl code needs to make ownerships decisions that actually depend on the usage.<p>Anyways, I guess this gets easier over time, right? Should I avoid using closures all over the place? Should my code look more like C and less like Haskell?<p><i>[edit] great answers all, providing useful context, thanks</i>
评论 #24295408 未加载
评论 #24295632 未加载
评论 #24295497 未加载
评论 #24295430 未加载
评论 #24299775 未加载
评论 #24295625 未加载
评论 #24298404 未加载
评论 #24295902 未加载
评论 #24298355 未加载
评论 #24300026 未加载
kumarvvrover 4 years ago
So, I want to learn Rust. I am a C# &#x2F; Python programmer, experienced.<p>Are there any particular set of problems that I can solve systematically, so that I can learn all the features of Rust?
评论 #24295523 未加载
评论 #24298881 未加载
评论 #24296901 未加载
评论 #24295478 未加载
评论 #24298419 未加载
评论 #24297230 未加载
评论 #24296625 未加载
评论 #24296999 未加载
评论 #24296908 未加载
评论 #24295698 未加载
评论 #24295934 未加载
评论 #24295558 未加载
评论 #24297229 未加载
thomasahleover 4 years ago
If anyone wants to know more about const fns, see <a href="https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;reference&#x2F;items&#x2F;functions.html#const-functions" rel="nofollow">https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;reference&#x2F;items&#x2F;functions.html#con...</a><p>It is the Rust way of specifying a function as being _pure_. In other words the output is dependent only on the function arguments, and not on any external state.<p>This means they can be evaluated at compile time. I suppose in the future, it could also allow better compiler optimizations.
评论 #24295339 未加载
评论 #24295622 未加载
评论 #24295674 未加载
kevinastoneover 4 years ago
Glad to see `Option::zip` stabilized. I tend to write such a helper in many of my projects to collect optional variables together when they&#x27;re coupled. Really improves the ergonomics doing more railroad-style programming.
评论 #24299756 未加载
LEARAXover 4 years ago
The quality of life improvements to cargo look very nice, and I feel that rust wouldn&#x27;t be remotely as successful without such a tool. I&#x27;m very glad I won&#x27;t have to be manually picking target directories out of my borg backups anymore when I&#x27;m running out of disk space.
corditeover 4 years ago
These const fn’s are cool, but won’t this also lead to long compile times down the road?
评论 #24295382 未加载
评论 #24295368 未加载
orthecreedenceover 4 years ago
Awesome! Any idea when relative links will be available in rustdoc? Seems like it&#x27;s just on the edge of stabilizing (<a href="https:&#x2F;&#x2F;github.com&#x2F;rust-lang&#x2F;rust&#x2F;pull&#x2F;74430" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;rust-lang&#x2F;rust&#x2F;pull&#x2F;74430</a>) but I&#x27;m curious how long it takes to see in a release after this happens.
评论 #24295591 未加载
fmakunboundover 4 years ago
&gt; if, if let, and match<p>&gt; while, while let, and loop<p>&gt; the &amp;&amp; and || operators<p>Common Lisp user here. Why just that? How come you can’t have the entire language as well as all your language customizations available at compile time for evaluation?
评论 #24301743 未加载
djhworldover 4 years ago
Is there a resource that explains what const functions are and why you would use them?
评论 #24298314 未加载
daitangioover 4 years ago
Can Mozilla layoffs (on Servo team) impact Rust future? It is just s question to understand if there are others big rust project healty out of there. Just curious
评论 #24318833 未加载
echelonover 4 years ago
`const fn` improvements are amazing!<p>I can&#x27;t wait for when we&#x27;ll be able to `const fn` all the things. Regex, expensive constants that feel as though they should be literals, etc.