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.

Good Practices for Writing Rust Libraries

138 pointsby jaxonduover 9 years ago

6 comments

jerfover 9 years ago
This isn&#x27;t really specific to Rust, but, while I wouldn&#x27;t necessarily do all this stuff while working through a tutorial on Rust, the start of a brand new language is a great time to learn how to set up this sort of stuff on your code from the very beginning. By definition, you must not have a lot of pre-existing Rust code. :)<p>Many of these sorts of things are hell to retrofit on to existing code, but if you integrate them into your workflow early, just shy of free over time to use all along. It&#x27;s &quot;just shy of free&quot; because the tools themselves train you over time so that you get to the point where you start with conforming code, and the tools are just cleaning up occasional slips rather than requiring you to rewrite everything. So, you actually still net out less effort than trying to retrofit later by making fewer mistakes overall in the first place.<p>I really can&#x27;t recommend this enough when you&#x27;re greenfielding something. It&#x27;s so cheap to start out doing the right thing and so very, very hard to fix it later....<p>(Obviously, you need to tweak a few things during prototype&#x2F;exploration, like requirements for docs, but a lot of this stuff is still useful right away.)
steveklabnikover 9 years ago
A lot of the stuff that interests me is how much this focuses on making things automatic. Use compiler plugins to automatically check your code, use rustfmt to automatically reformat your code, use highfive to automatically greet new contributors, use homu to automatically ensure good CI, use Travis to automatically upload docs, etc.<p>I like things that are automatic. That way, I don&#x27;t forget about them.
评论 #10447831 未加载
评论 #10447827 未加载
评论 #10448667 未加载
评论 #10447793 未加载
merbover 9 years ago
What Rust and Go still misses is still the good IDE. On the C&#x2F;C++ side you could even use Eclipse and IntelliJ or Visual Studio. And still if you don&#x27;t like an IDE you could use an editor, however on rust &#x2F; golang you are forced to the editor, which could be aweful if the project is grown &#x2F; big, at least for me. Good practices are helping, however the best editorconfig could help you if your codepage grown too big and you don&#x27;t remeber the function of a specific struct&#x2F;class&#x2F;whatever.
评论 #10448503 未加载
评论 #10447914 未加载
评论 #10447939 未加载
评论 #10448002 未加载
评论 #10448028 未加载
cpetersoover 9 years ago
It would be nice if the Rust documentation had a centralized list of std and core traits. For example, I see a summary of the std crate&#x27;s exported types, modules, and macros but no traits. Such a list would be useful for library developers who want to maximize their library&#x27;s potential for reuse by implementing all relevant core and std traits.<p><a href="https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;nightly&#x2F;std&#x2F;index.html" rel="nofollow">https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;nightly&#x2F;std&#x2F;index.html</a>
评论 #10449801 未加载
jzwinckover 9 years ago
What about good practice for the actual writing of Rust library code? I know C++ and there we have advice such as not reordering virtual methods, not using STL types in public APIs, not reusing enum values, exception safety, RAII, etc. What about in Rust? What are some guidelines for writing libraries which will give their users maximum convenience and safety? Is there a stable ABI, and if so what do library implementers need to know about it? How about writing C APIs in Rust?
评论 #10449847 未加载
Keatsover 9 years ago
Anyone knows when the compiler plugins will be stable?
评论 #10447937 未加载
评论 #10450107 未加载
评论 #10450234 未加载