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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Rust Starter Kit 2020

348 点作者 psxuaw超过 4 年前

16 条评论

riskable超过 4 年前
This is awesome! I&#x27;ve been developing firmware in Rust for a Hall Effect keyboard (with springless, magnetic separation switches!) I&#x27;m developing&#x2F;inventing (just ordered the first PCBs!). I really wish we had something similar in the embedded Rust ecosystem as a lot of the crates mentioned don&#x27;t support #![no_std] (declaration you make at the top of your Rust code to indicate that the compiler should <i>not</i> include the standard library).<p>The world of embedded Rust seems to be developing incredibly fast. Especially since there&#x27;s so much hardware that you can use with it now and more is on the way (especially in the world of RISC-V... Holy crap there&#x27;s a lot of interesting and exciting hardware coming!). As a result of that I seem to be regularly encountering situations where I try to do something basic but no one has &quot;made a crate for that yet&quot; (that works with #![no_std]).<p>Just the other day I found out just how difficult it is to benchmark something (i.e. grab the current time, do something, get the time again, then subtract the difference... It&#x27;s really, <i>really</i> complicated! Way moreso than it should be). If someone wanted to make a name for themselves by developing widely-used software <i>now is the time</i> to make your mark! The world of embedded Rust is waiting for you!<p>FYI: I&#x27;m still a newbie when it comes to Rust but I was able to develop a <i>universal</i> driver (works with any hardware platform) for working with 74HC4067 and 74HC4051 analog multiplexers in just a few days... <a href="https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;analog-multiplexer" rel="nofollow">https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;analog-multiplexer</a>
评论 #24675025 未加载
评论 #24672430 未加载
评论 #24673067 未加载
3PS超过 4 年前
Really awesome list! Some thoughts:<p>1) For error handling, I think anyhow and thiserror have been gaining popularity for applications and libraries, respectively. There&#x27;s also eyre, a fork of anyhow with some more options apparently, and color-eyre, which is a variation of eyre for colorful backtraces. Long story short, yeah, there&#x27;s a lot of crates.<p>2) I&#x27;ve heard good things about sqlx as an alternative to diesel that lets you write raw type-safe SQL into your code and get it checked at compile time. It has good async support too.<p>3) I would probably mention async-std as an alternative to tokio.
评论 #24673201 未加载
评论 #24674007 未加载
johnsoft超过 4 年前
I&#x27;d suggest once_cell instead of lazy_static. No macros, faster compiles.<p><a href="https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;once_cell" rel="nofollow">https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;once_cell</a>
评论 #24672334 未加载
steveklabnik超过 4 年前
This is a good list. cargo tree was upstreamed into Cargo, so you don’t even need to install it via a package these days.
csnover超过 4 年前
As a newer Rust developer, this is a very helpful list—trying to find appropriate crates has really been a crap shoot. One thing I can note from personal experience, though, is that saying `structopt` “is relatively slow to compile and doesn’t produce the tiniest code” is quite an understatement—its binary overhead is 379.6KiB and compile time is over 15 seconds[0]! Parsing args is a <i>tiny</i> part of an application, so giving over so much time and memory is crazy to me. I’ve personally settled on using pico, which doesn’t use proc macros so you don’t get the sugar of a declarative arguments object, but it’s fast to build and almost as small as the lightweight recommendation `argh`.<p>[0] <a href="https:&#x2F;&#x2F;github.com&#x2F;RazrFalcon&#x2F;pico-args#alternatives" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;RazrFalcon&#x2F;pico-args#alternatives</a>
评论 #24674943 未加载
dathinab超过 4 年前
Missing: `async-std`<p>Which provides a interface like the std library but async. (Through tokio copied a lot of this by now).<p>It uses the same execution implementation as `smol` and generally most of the code from it is shared with `smol` through internal dependencies like `async-executor`.<p>Through lie tokio it&#x27;s a bit bigger then `smol` which affects compiler times.
评论 #24675155 未加载
评论 #24672596 未加载
Communitivity超过 4 年前
I read through this and have to say I disagree with several of the points. Rather than go through them all one by one, I&#x27;ll just say that my experience with several of these create differ greatly (tokio in particular), and several of the crates recommended would not be the ones I suggested. The http section also doesn&#x27;t mention Actix or Tide or Rocket. Then again, I am relatively new to Rust myself (1 year), so take this with a grain of salt.
ZephyrBlu超过 4 年前
Coming from Python and having no Rust experience, it&#x27;s odd to me that these are all external packages and not apart of the standard library.<p>For instance, Python provides HTTP, regex, logging, etc. out of the box.<p>Is this a difference in philosophy between Python and Rust? (Batteries-included vs unix?)
评论 #24672461 未加载
评论 #24672481 未加载
评论 #24672576 未加载
评论 #24673404 未加载
评论 #24672467 未加载
评论 #24672469 未加载
评论 #24672692 未加载
评论 #24672509 未加载
评论 #24672963 未加载
fluffything超过 4 年前
&gt; [Things I avoid] parking_lot: More compact and efficient implementations of the standard synchronization primitives. [goes on about efficiency...]<p>lol, really? No, like, not at all.<p>Parking lot has 1 killer feature, and 1 killer feature only, and this feature makes using the standard synchronization primitives _almost always_ the wrong choice for almost all applications:<p><pre><code> DEADLOCK DETECTION </code></pre> That&#x27;s right, if you ever need a Mutex, chances are that your program might run into a deadlock at some point. Do your future self a huge favor and don&#x27;t use the standard library&#x27;s std::Mutex. Instead, use parking_lot::Mutex, turn on deadlock detection at compile-time, and save your future self potentially hours of trying to figure out what your program is doing, why is it deadlocking, and how to fix it.<p>parking_lot::Mutex panics if your program deadlocks, printing out the backtrace of each thread involved in the deadlock. This makes discovering, understanding, and fixing dead-locks a 5 minute issue, that&#x27;s easily and quickly discovered during development in the minutes after introducing a deadlock bug.<p>I mean, you are completely right that, on top of that, parking_lot synchronization primitives are much much faster than those in the standard library. But that&#x27;s only the cherry on top.<p>---<p>FWIW, nice post, I agree with all your judgements there. If you are looking for an async runtime that&#x27;s smaller than tokio, check out the `smol` crate. For a thread-pool, i either just use rayon&#x27;s (you can just push tasks onto its thread pool), or the futures&#x27;s simple thread pool from the futures crate.
评论 #24672851 未加载
评论 #24673322 未加载
评论 #24674718 未加载
评论 #24672822 未加载
CJefferson超过 4 年前
I really like this, I wish more languages had this, unlike a list which gives 200 package to do X, with no idea which is best.<p>My only comment is I prefer &#x27;tracing&#x27; to &#x27;log&#x27; for logging, but log will do fine.
oefrha超过 4 年前
&gt; Media codecs – Various<p>&gt; Not aware of any great encoders... Video, I haven’t used enough to have an opinion on.<p>If you don&#x27;t mind having a -sys dependency, you can use an FFmpeg binding. There&#x27;s ffmpeg-next[1] (which is a continuation of the abandoned ffmpeg[2] crate), and a few others I have no experience with.<p>[1] <a href="https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;ffmpeg-next" rel="nofollow">https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;ffmpeg-next</a><p>[2] <a href="https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;ffmpeg" rel="nofollow">https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;ffmpeg</a>
__leo_m__超过 4 年前
Very good list. There have recently been similar posts about what crates to choose. Always followed by discussions about some of the choices.<p>In professional environments where besides the product time to market and costs are the key points, we don&#x27;t want to spend time on this kind of discussions and decisionmaking. Or taking risks using libs with 0.x versions.<p>It really is a pitty that the decision to keep essential stuff out of the standard lib is limiting Rusts usage in professional environments. Developer resoureces are another reason, but this is a chicken egg problem. The standard lib issue can be solved much easier.
lumost超过 4 年前
Would be really interested in a solid tree&#x2F;list&#x2F;doubly linked list structure. The borrow checker appeared to make the construction of such a structure impossible.
评论 #24672761 未加载
评论 #24676979 未加载
IshKebab超过 4 年前
For thread pools I&#x27;m pretty sure you can use Rayon.<p>I agree with 99% of this but I can&#x27;t agree with Crossbeam. I use it basically every time I need multiple threads because you always end up needing `select!()`. As far as I know std doesn&#x27;t have anything like that which makes its channels rather useless.
评论 #24675627 未加载
scudd超过 4 年前
Nice list. Maybe considering adding clap as another option under the section on command line parsing
jpeter超过 4 年前
Is there a list like this for C#?
评论 #24672826 未加载
评论 #24673096 未加载