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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Rust from a Gopher – Lessons 3 and 4

49 点作者 BookPage超过 4 年前

7 条评论

CodesInChaos超过 4 年前
The part complaining about missing details in the error message seems weird. You get a pretty detailed error even without using `--explain`:<p><pre><code> error[E0384]: cannot assign twice to immutable variable `x` --&gt; src&#x2F;main.rs:4:5 | 3 | let x = 3; | - | | | first assignment to `x` | help: make this binding mutable: `mut x` 4 | x = 5; | ^^^^^ cannot assign twice to immutable variable error: aborting due to previous error; 2 warnings emitted For more information about this error, try `rustc --explain E0384`.</code></pre>
评论 #24979450 未加载
baq超过 4 年前
I quite liked the tongue-in-cheek style.<p>&gt; The book really led me to believe there are literally two types of strings in Rust<p>Oh you sweet summer child :) The joys of discovering that on lower levels, a String is not a str is an OsStr but is not a str and why that is are coming back to me.<p>Also, I particularly like the periodic table of rust types:<p><a href="https:&#x2F;&#x2F;cosmic.mearie.org&#x2F;2014&#x2F;01&#x2F;periodic-table-of-rust-types&#x2F;" rel="nofollow">https:&#x2F;&#x2F;cosmic.mearie.org&#x2F;2014&#x2F;01&#x2F;periodic-table-of-rust-typ...</a><p>This compared to almost any other language should tell you that Rust trades compilation speed for strictness and execution speed. It&#x27;s really helpful to understand what you need to care about if you don&#x27;t have a garbage collector working for you.
评论 #24978751 未加载
chrisdhal超过 4 年前
&gt; const MAX_POINTS: u32 = 100_000; &#x2F;&#x2F; wtf is this ugly numeric shit<p>Java has had this since Java7 and Go has had it since at least 1.13, so I&#x27;m not sure why he hasn&#x27;t seen it based on his other experiences.
评论 #24980067 未加载
评论 #24979338 未加载
评论 #24979230 未加载
donatj超过 4 年前
The author may be interested to know that I am receiving CSRF errors from Disqus when trying to comment on the article itself.
dathinab超过 4 年前
Btw. there are parts in the standards library which are not suited for learning rust by understanding it.<p>Not only might your run into some but trivial edge case complexity which add the user of the standard library you don&#x27;t have to know about at all but you will also run into a bunch of unstable nightly and as such often but that well documented thinks, some of which might never get stabilized.<p>So if you start learning rust this can lead to unnecessary confusion.<p>Btw. one of the reasons I like rust is that for a lot of the (more hidden) complexity you get away without knowing it and (important) if you don&#x27;t get away with it you run into a compiler error. Which is in difference to C++ where a bunch of the (more hidden) complexity has quite a high potential to screw you up if you run into it without knowing about it.
评论 #24979651 未加载
Ygg2超过 4 年前
&gt; I see a very sharp knife; but this knife is completely and utterly shrouded and encased in tamper-proof, child-proof, thief-proof hardened and sealed plastic shells.<p>Yeah, because that knife is made of uranium.<p>Anyone not handling that uranium as they should, should be shunned, isolated and enclosed in a lead vault.
评论 #24978749 未加载
LandR超过 4 年前
WHy in the rust code snippets do all the spaces show as up _ ?<p>Oh, odd, it&#x27;s my dark mode addon.
评论 #24978969 未加载