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.

The Plan for the Rust 2021 Edition

279 pointsby cautionabout 4 years ago

18 comments

RhodoGSAabout 4 years ago
Decided to start learning rust last month. I have very little previous programming experience and the journey has been a bit brutal so far so i wanted to share my &quot;Learning journey&quot;.<p>&quot;The book&quot; although a great book, is fairly dense with no exercises. Rustlings[1] help me apply alot of my learning and i supplemented the book with Tensors programming tutorials on youtube [2]. Recently i started developing a game in Bevy[3] and although its a bit over my head at this point i&#x27;ve managed to get a character moving and be able to kill a monster and receive a drop. My motivations for learning rust was to be familiar with substrate [4] as i&#x27;d like to switch careers into programming. Would also love any recommendations&#x2F;tips &amp; tricks by any experience rustaceans!<p>[1]<a href="https:&#x2F;&#x2F;github.com&#x2F;rust-lang&#x2F;rustlings" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;rust-lang&#x2F;rustlings</a> [2]<a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=EYqceb2AnkU&amp;list=PLJbE2Yu2zumDF6BX6_RdPisRVHgzV02NW&amp;index=1" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=EYqceb2AnkU&amp;list=PLJbE2Yu2zu...</a> [3]<a href="https:&#x2F;&#x2F;bevyengine.org&#x2F;learn&#x2F;book&#x2F;getting-started&#x2F;" rel="nofollow">https:&#x2F;&#x2F;bevyengine.org&#x2F;learn&#x2F;book&#x2F;getting-started&#x2F;</a> [4]<a href="https:&#x2F;&#x2F;www.substrate.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.substrate.io&#x2F;</a>
评论 #27125312 未加载
评论 #27128003 未加载
评论 #27125645 未加载
asimpletuneabout 4 years ago
I love how subtle and thoughtful these changes are. Rust isn’t only a great language, it’s a model of how technology can be built.
评论 #27120691 未加载
评论 #27122662 未加载
maxioaticabout 4 years ago
This little bit, which is not coming in this version but is enabled by it:<p>&gt; f&quot;&quot; as a short-hand for a format string. For example, f&quot;hello {name}&quot; as a short-hand for the equivalent format_args!() invocation.<p>I&#x27;m excited by. I like the f-string formatting in Python quite a bit.
评论 #27120732 未加载
评论 #27121010 未加载
评论 #27120835 未加载
评论 #27120699 未加载
ebingdomabout 4 years ago
I love Rust, but one thing that seems like a glaring design flaw is that adding a new trait implementation can change the behavior of existing code. This is very counterintuitive, because it seems like a purely additive change. In my opinion, the convenience of auto-dereferencing &quot;as much as possible&quot; to make method call syntax magically work through the indirection of references is not worth the lack of stability guarantees that it causes. This isn&#x27;t a normal kind of breakage where the compiler points out what code you need to fix; this is a much worse kind of breakage where you might not even realize your code now behaves differently. In my opinion, the notion of &quot;editions&quot; is not an acceptable solution to this.<p>For a language that prioritizes safety, there are a surprising number of gotchas in Rust (another example is the large number of partial functions in the standard library).
评论 #27122920 未加载
评论 #27122061 未加载
评论 #27121988 未加载
评论 #27126974 未加载
yakubinabout 4 years ago
One thing that I repeatedly bump into in Rust is the oddity of multi-argument functions. To explain the problem, let&#x27;s look at another language for a moment: in SML there is no such thing as multi-argument functions per se. There are two ways to write them anyway:<p>* the function&#x27;s argument is a tuple (this is the more common way, not only in SML, but also how it&#x27;s done most commonly in maths);<p>* currying.<p>I&#x27;m not a fan of currying, because it singles out the first argument over the others. However, the first approach (tuples) is very ergonomic, because now you can pass the return value of one function as an argument to a &quot;multi-argument&quot; function. One application of that is function composition. But another is a simple map. I&#x27;ve lost count of how many times in Rust I had an &quot;o: Option&lt;(A, B)&gt;&quot; and a &quot;f: fn(A, B) -&gt; C&quot; and couldn&#x27;t call &quot;o.map(f)&quot;; instead the programmer is forced to write more noisy code with lambdas. And lambdas sometimes don&#x27;t play well with the borrow checker for mysterious reasons (even those that don&#x27;t capture anything).<p>Also, I think it would be nice if the compiler generated named discriminants for every enum. Currently, &quot;std::mem::discriminant&quot; returns an opaque &quot;std::mem::Discriminant&lt;T&gt;&quot; (which doesn&#x27;t have a name). In order to compare discriminants I need to create a full-blown enum value and extract the discriminant from it later. I&#x27;ve worked around this problem by using the &quot;strum&quot; crate, which has a macro to produce another (plain) enum, but having the discriminant type be named &quot;std::mem::Discriminant&lt;T&gt;&quot; (to signal the connection to the original enum) <i>and</i> have named variants at the same time would be the best of both worlds.<p>EDIT: If I knew more about possible breakage caused by my first suggestion, I could probably start working on an RFC. However, I feel I don&#x27;t have enough knowledge about Rust to anticipate that.<p>For my second suggestion I think I&#x27;m going to try to propose that. I&#x27;m reading the docs on the process now.
评论 #27120954 未加载
评论 #27122482 未加载
评论 #27120634 未加载
评论 #27123090 未加载
评论 #27126101 未加载
RcouF1uZ4gsCabout 4 years ago
&gt; However, note that Rust is a project run by volunteers. We prioritize the personal well-being of everyone working on Rust over any deadlines and expectations we might have set. This could mean delaying the edition a version if necessary, or dropping a feature that turns out to be too difficult or stressful to finish in time.<p>What a refreshing take! One of the things I have admired about Rust is the effort from the start to build a healthy, welcoming, non-toxic community, and to prioritize personal well-being.
评论 #27120895 未加载
nynxabout 4 years ago
This doesn&#x27;t require an edition change, but I&#x27;m really looking forward to custom, per-collection allocator support. It&#x27;s in nightly right now and very nice to use.
评论 #27120142 未加载
floatbothabout 4 years ago
&gt; Starting in Rust 2021, closures will only capture the fields that they use<p>Holy shit yes. Thank you thank you thank you. This fixes my biggest annoyance so far!
dluanabout 4 years ago
&gt; However, note that Rust is a project run by volunteers. We prioritize the personal well-being of everyone working on Rust over any deadlines and expectations we might have set. This could mean delaying the edition a version if necessary, or dropping a feature that turns out to be too difficult or stressful to finish in time.<p>I like this.
sodality2about 4 years ago
I am actually excited to learn rust as I try to learn lower level languages. Not so for any other language.
评论 #27121320 未加载
评论 #27122225 未加载
dmkolobovabout 4 years ago
Lack of IntoIterator for arrays and disjoint capture are some of the biggest pain-points in writing Rust code for me! Very excited to see these changes on the map.
Trasterabout 4 years ago
Man I feel like an idiot. I read the first paragraph and I&#x27;m like &quot;that&#x27;s just versions&quot; and then I read the next few paragraphs and I&#x27;m like &quot;Yeah but your dependencies are going to screw you&quot;.<p>I&#x27;m not sold on the raw identifier syntax and we&#x27;ll see if the changes are actually as good as they claim, but in general this seems like a great way of doing language &#x27;versions&#x27;.<p>Rust is definitely learning from the past and I&#x27;m really interested see what we learn from how they fuck up too
评论 #27124404 未加载
评论 #27124813 未加载
apiabout 4 years ago
These seem pretty minimal. Most of the code I can recall writing or have seen would require no changes or maybe a one liner here and there.
评论 #27120704 未加载
评论 #27120464 未加载
评论 #27120912 未加载
qzwabout 4 years ago
&gt; Instead, we decided to add the [IntoIterator] trait implementation in all editions (starting in Rust 1.53.0), but add a small hack to avoid breakage until Rust 2021.<p>Eh, why not. We nerds are used to retconning in all the sci-fi universes anyway.
pjmlpabout 4 years ago
&gt; It has been suggested many times to &quot;only implement IntoIterator for arrays in Rust 2021&quot;. However, this is simply not possible. You can&#x27;t have a trait implementation exist in one edition and not in another, since editions can be mixed.<p>Another example how editions aren&#x27;t much different than mixing language versions on other eco-systems, just another way of achieving similar results.
AnonCabout 4 years ago
The page source for this post has this comment at the end:<p><pre><code> &lt;!-- If you really can&#x27;t wait, many features are already available on Rust [Nightly](https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;book&#x2F;appendix-07-nightly-rust.html) with `-Zunstable-options --edition=2021`. --&gt;</code></pre>
Flex247Aabout 4 years ago
Really excited to see the syntax becoming more consistent!<p>I am looking forward to master Rust in the coming 4-5 years.
评论 #27120019 未加载
markwisdeabout 4 years ago
“We can’t add tryinto to the prelude, as a solution we’re adding tryinto”<p>What?
评论 #27120799 未加载