TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Rust 1.50

378 点作者 _xrjp超过 4 年前

18 条评论

brundolf超过 4 年前
&gt; Some types in Rust have specific limitations on what is considered a valid value, which may not cover the entire range of possible memory values. We call any remaining invalid value a niche, and this space may be used for type layout optimizations. For example, in Rust 1.28 we introduced NonZero integer types (like NonZeroU8) where 0 is a niche, and this allowed Option&lt;NonZero&gt; to use 0 to represent None with no extra memory.<p>I didn&#x27;t know about this, and it&#x27;s super cool. It&#x27;s part of a broader pattern where the rigid constraints Rust can impose on code allow both the compiler and the user to do things that would be wildly dangerous in a less-strict language.
评论 #26103106 未加载
评论 #26110970 未加载
评论 #26105255 未加载
评论 #26103071 未加载
pjungwir超过 4 年前
I don&#x27;t use Rust often (sadly), but I really appreciate its goals and its steady progress. I read every one of these Rust 1.x stories on HN. Around Christmas I made an n-player chess clock with Rust and websockets [0] (because my friends are really slooow Agricola players :-), and it was incredibly easy compared to my first projects 5 years ago. I can&#x27;t believe it&#x27;s been that long. So thank you to all the folks working on it, and also thank you to everyone helping out 5-year newbies like me. Especially steveklabnik, I think you&#x27;ve helped me personally several times. :-)<p>[0] <a href="https:&#x2F;&#x2F;github.com&#x2F;pjungwir&#x2F;multiclock" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;pjungwir&#x2F;multiclock</a>
weinzierl超过 4 年前
I&#x27;ve been doing Rust for a while now, but this is the first time I&#x27;ve heard about the <i>niche</i> concept[1]. Sounds really useful.<p>I know that other languages have subranges or refinement types but <i>niches</i> seem to solve a different problem - namely to use the &quot;holes&quot; in a data type for optimization. Does any other language have some comparable concept to <i>niches</i> in Rust?
评论 #26109524 未加载
pimeys超过 4 年前
I hope 1.51 brings the new cargo resolver to stable. I was fighting with a problem recently, solved in the new resolver. If we&#x27;d think a dependency such as:<p><pre><code> [target.&#x27;cfg(target_os = &quot;macos&quot;)&#x27;.dependencies] foo = { version = &quot;1&quot;, features = [&quot;x&quot;] } [target.&#x27;cfg(not(target_os = &quot;macos&quot;))&#x27;.dependencies] foo = { version = &quot;1&quot;, features = [] } </code></pre> With the current resolver, the dependency `foo` will always be compiled with a feature `x`, no matter which target os you&#x27;re using. Debugging this took me a while and I was surprised it&#x27;s actually just how the current resolver works.
varajelle超过 4 年前
I am happy that bool::then is stable. I can simplify quite some code by removing the `else { None }` branch
评论 #26103314 未加载
staticassertion超过 4 年前
const generics are a feature I&#x27;ve been looking forward to since 1.0, really cool to see that work making it to stable.<p>This solves another of the ergonomic issues in Rust. It really feels like within 2021 Rust will hit a point where it feels totally consistent.
评论 #26102877 未加载
评论 #26102698 未加载
slmjkdbtl超过 4 年前
I&#x27;m not familiar with Rust&#x27;s rfc &#x2F; implementation &#x2F; go stable flow, but I&#x27;m curious how f32::clamp took so many years to go stable
评论 #26104763 未加载
评论 #26104841 未加载
candied_scarf超过 4 年前
im still waiting for fixes for <a href="https:&#x2F;&#x2F;github.com&#x2F;rust-lang&#x2F;rust&#x2F;issues&#x2F;40552" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;rust-lang&#x2F;rust&#x2F;issues&#x2F;40552</a> and <a href="https:&#x2F;&#x2F;github.com&#x2F;rust-lang&#x2F;rust&#x2F;issues&#x2F;75263" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;rust-lang&#x2F;rust&#x2F;issues&#x2F;75263</a> in one of these releases<p>lots of upvotes for them too since its for privacy in the compiler
评论 #26103855 未加载
haolez超过 4 年前
I was just wondering... is there any hope to have minimalist Rust compilers? Something like TinyCC for C[0]?<p>[0] <a href="https:&#x2F;&#x2F;tiny.cc&#x2F;" rel="nofollow">https:&#x2F;&#x2F;tiny.cc&#x2F;</a>
评论 #26104493 未加载
评论 #26107285 未加载
评论 #26106125 未加载
评论 #26106469 未加载
评论 #26104479 未加载
no_wizard超过 4 年前
Disclaimer: I&#x27;m new to Rust and lower-level programming of this type in general. The &#x27;lowest&#x27; level language I&#x27;ve worked with on the regular before this is C#[2]<p>I know Rust already has Tuples[0], so I&#x27;m assuming Const Generic Indexing For Arrays[1] is a happy path for the compiler to optimize what amounts to a finite sized Generic Tuple? (Finite size in terms of memory not elements)<p>Excellent feature, I just seem some (admittedly only high level) surface overlap in this language feature.<p>[0]: <a href="https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;rust-by-example&#x2F;primitives&#x2F;tuples.html" rel="nofollow">https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;rust-by-example&#x2F;primitives&#x2F;tuples....</a><p>[1]: <a href="https:&#x2F;&#x2F;blog.rust-lang.org&#x2F;2021&#x2F;02&#x2F;11&#x2F;Rust-1.50.0.html#const-generic-array-indexing" rel="nofollow">https:&#x2F;&#x2F;blog.rust-lang.org&#x2F;2021&#x2F;02&#x2F;11&#x2F;Rust-1.50.0.html#const...</a><p>[2]: Which, while generally accepted to be a strongly typed language, is not near the level of Rust
评论 #26102692 未加载
评论 #26102883 未加载
mkesper超过 4 年前
Seems to have vanished, was put out too early?<p>OK, can see it now, too. Caches...
评论 #26102584 未加载
评论 #26102999 未加载
评论 #26102494 未加载
评论 #26102508 未加载
nitsky超过 4 年前
With all the exciting changes coming to Rust soon, I think this release would be appropriately called &quot;the calm before the storm&quot;.
评论 #26136199 未加载
vlovich123超过 4 年前
Are there any plans to extend the ability so that user code can use niche values that aren&#x27;t 0? Unless I failed at figuring out how to find the relevant docs, I only see NonZero formally documented but this release is clearly utilizing -1 instead (&amp; I&#x27;m assuming it&#x27;s not just doing +1&#x2F;-1 math when accessing just to leverage NonZero).
评论 #26103824 未加载
da_big_ghey超过 4 年前
I am looking to learn Rust, but am wondering, what resources are good for learning the latest language version? I don&#x27;t want to pick up something that teaches me an old version so I then have to go and get used to the new one.
评论 #26102942 未加载
评论 #26102935 未加载
评论 #26103056 未加载
Waterluvian超过 4 年前
So does all this const work not break any existing usage but promotes the functions to &quot;we can know more about and do more with at compile time&quot;?
评论 #26106114 未加载
cevans01超过 4 年前
Couldn&#x27;t any negative number be used as a niche for file descriptors in Unix? Could Option&lt;File&gt; use -2 to specify None?
评论 #26103211 未加载
评论 #26103000 未加载
coldtea超过 4 年前
<p><pre><code> pub fn clamp(self, min: f64, max: f64) -&gt; f64 </code></pre> Rust has generics iirc, so why there&#x27;s this?
评论 #26106527 未加载
AlchemistCamp超过 4 年前
Really too bad that after another minor version, I&#x27;m still seeing:<p><pre><code> Warning: can&#x27;t set `control_brace_style = ClosingNextLine`, unstable features are only available in nightly channel. </code></pre> It seems like a trivial and desirable feature but it&#x27;s only been available in nightly for over a year now. The poor (and rigidly enforced) default on this same issue was why I ripped prettier out of every project I work on.<p>Also, I don&#x27;t know how hard it is to contribute to this kind of issue, but I&#x27;m glad to put in some time (with my still newbie level of Rust skills) if that can help resolve it.
评论 #26111903 未加载