{"id":13440339,"url":"https://github.com/mre/idiomatic-rust","last_synced_at":"2025-05-14T06:12:04.814Z","repository":{"id":38428879,"uuid":"90136504","full_name":"mre/idiomatic-rust","owner":"mre","description":"🦀 A peer-reviewed collection of articles/talks/repos which teach concise, idiomatic Rust.","archived":false,"fork":false,"pushed_at":"2024-05-10T09:05:17.000Z","size":4283,"stargazers_count":6969,"open_issues_count":1,"forks_count":215,"subscribers_count":159,"default_branch":"master","last_synced_at":"2025-04-11T00:48:29.070Z","etag":null,"topics":["ergonomics","idiomatic","idiomatic-rust","rust"],"latest_commit_sha":null,"homepage":"http://idiomatic.rs","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mre.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"mre"}},"created_at":"2017-05-03T10:21:10.000Z","updated_at":"2025-04-11T00:48:05.000Z","dependencies_parsed_at":"2023-11-07T04:13:07.416Z","dependency_job_id":"d4a42b7a-6aee-48fc-9b93-9481fa3f03b8","html_url":"https://github.com/mre/idiomatic-rust","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mre%2Fidiomatic-rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mre%2Fidiomatic-rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mre%2Fidiomatic-rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mre%2Fidiomatic-rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mre","download_url":"https://codeload.github.com/mre/idiomatic-rust/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254080120,"owners_count":22011325,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ergonomics","idiomatic","idiomatic-rust","rust"],"created_at":"2024-07-31T03:01:21.842Z","updated_at":"2025-05-14T06:12:04.807Z","avatar_url":"https://github.com/mre.png","language":"Rust","readme":"\u003c!--\n⚠️⚠️ WARNING: This file is generated by `make render`. Do not edit manually!\nSee `CONTRIBUTING.md` for more information.\n--\u003e\n\n\u003cpicture \u003e\n  \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"assets/idiomatic-rust-dark.png\"\u003e\n  \u003cimg src=\"assets/idiomatic-rust.png\" /\u003e\n\u003c/picture\u003e\n\n[![Check Links](https://github.com/mre/idiomatic-rust/workflows/Check%20Links/badge.svg)](https://github.com/mre/idiomatic-rust/actions/workflows/check_links.yml)\n\nThis repository collects resources for writing clean, idiomatic Rust code.\nYou can find a sortable/searchable version of this list [here](https://corrode.dev/idiomatic-rust/).\n\n\u003e _Idiomatic_ coding means following the conventions of a given language. It is\n\u003e the most concise, convenient, and common way of accomplishing a task in that\n\u003e language, rather than forcing it to work in a way the author is familiar with\n\u003e from a different language. - Adapted from [Tim\n\u003e Mansfield](https://github.com/tim-hr/stuff/wiki/Idiomatic-coding)\n\nContributions welcome! To add missing resources, [please refer to the contributing documentation](https://github.com/mre/idiomatic-rust/blob/master/CONTRIBUTING.md).\n\n## ⚙ Projects\n\n\n\n- [blessed.rs](https://blessed.rs/) — An unofficial guide to the Rust ecosystem. Suggestions for popular, well-maintained crates.\n\n- [cheats.rs - Idiomatic Rust tips](https://cheats.rs/) — A list of quick tips to make your code more idiomatic.\n\n- [clippy](https://github.com/rust-lang/rust-clippy) — A bunch of lints to catch common mistakes and improve your Rust code.\n\n- [Elements of Rust](https://github.com/ferrous-systems/elements-of-rust) — A collection of software engineering techniques for effectively expressing intent with Rust.\n\n- [Patterns](https://rust-unofficial.github.io/patterns/) — A catalogue of design patterns in Rust.\n\n- [Possible Rust](https://www.possiblerust.com/) — A blog for intermediate Rust programmers exploring real-world code and design patterns.\n\n- [Rust Anthology](https://github.com/brson/rust-anthology) — The best short-form writing about Rust, collected.\n\n- [Rust API Guidelines](https://rust-lang.github.io/api-guidelines/) — An extensive list of recommendations for idiomatic Rust APIs.\n\n- [Rust by Example](https://doc.rust-lang.org/rust-by-example/) — A community driven collection of example code which follow Rust best practices.\n\n## 🏋 Workshops\n\n\n\n- [Build your own JIRA with Rust](https://github.com/LukeMathWalker/build-your-own-jira-with-rust/) — A test-driven workshop to learn Rust by building your own JIRA clone!\n\n- [Comprehensive Rust](https://github.com/google/comprehensive-rust) — A four day Rust course developed by the Android team, covering all aspects of Rust.\n\n- [Ferrous Systems Teaching Material](https://ferrous-systems.github.io/teaching-material/index.html) — Free workshop material produced by Ferrous Systems for trainings.\n\n- [Hecto: Build your own text editor in Rust](https://www.flenker.blog/hecto/) — This is a series of blog posts that shows you how to build a text editor in Rust\n\n- [Idiomatic Rust Workshop](https://fettblog.eu/slides/idiomatic-rust/) — A talk/workshop about idiomatic Rust code focusing on effective use of existing syntax and design patterns\n\n- [PingCAP talent plan](https://github.com/pingcap/talent-plan) — A series of training courses about writing distributed systems in Rust.\n\n- [Procedural Macros Workshop](https://github.com/dtolnay/proc-macro-workshop) — A selection of projects designed to learn to write Rust procedural macros.\n\n- [Rust 101](https://101-rs.tweede.golf/) — A Rust University course by tweede golf.\n\n- [Rust Development at Sentry](https://develop.sentry.dev/rust/) — A document containing useful resources for getting started with Rust and adhering to Sentry coding principles.\n\n- [rust-lang/rustlings](https://github.com/rust-lang/rustlings) — Small exercises to get you used to reading and writing Rust code.\n\n## 📖 Books\n\n\n\n- [Command Line Applications in Rust](https://rust-cli.github.io/book) — A tutorial on how to write CLI apps in Rust, learning many aspects of the ecosystem.\n\n- [Command-Line Rust](https://github.com/kyclark/command-line-rust) — Learn the language by writing Rust versions of common Unix coreutils.\n\n- [Discover the world of microcontrollers through Rust!](https://rust-embedded.github.io/discovery/) — An introductory course on microcontroller-based embedded systems using Rust.\n\n- [High Assurance Rust](https://highassurance.rs/) — Developing secure and robust software, focusing on embedded-friendly data structures in Rust.\n\n- [Programming Rust: Fast, Safe Systems Development](https://www.oreilly.com/library/view/programming-rust-2nd/9781492052586/) — A comprehensive Rust Programming Guide that covers most of Rust's features in detail.\n\n- [Rust Atomics and Locks](https://marabos.nl/atomics/) — Helps Rust programmers of all levels gain a clear understanding of low-level concurrency.\n\n- [Rust Cookbook](https://github.com/rust-lang-nursery/rust-cookbook) — Examples that demonstrate good practices to accomplish common programming tasks in Rust.\n\n- [Rust for Rustaceans](https://nostarch.com/rust-rustaceans) — Covers how to design reliable, idiomatic, and ergonomic Rust programs based on best principles.\n\n## 📰 Articles\n\n\n\n### 2023\n\n- [Aim For Immutability in Rust](https://corrode.dev/blog/immutability/) — Explains why variables are immutable in Rust by default.\n  - [Compile-Time Invariants in Rust](https://corrode.dev/blog/compile-time-invariants/) — Shows how macros can be used to enforce invariants at compile-time.\n  \n\n### 2021\n\n- [Rust Number Conversion: Don't Follow the Book...](https://blog.notmet.net/2021/12/rust-number-conversion-dont-follow-the-book.../) — A blog post discussing the best practices for number conversion in Rust.\n  - [Hexagonal architecture in Rust](https://alexis-lozano.com/blog/hexagonal-architecture-in-rust-1/) — Describes how to build a Rust service using domain driven design and a test-first approach.\n  - [Wrapping errors in Rust](https://edgarluque.com/blog/wrapping-errors-in-rust) — Wrapping 'reqwest::Error' and a custom error type as an enum to make library usage easier.\n  - [Aiming for idiomatic Rust](https://web.archive.org/web/20221203043933/https://shane-o.dev/blog/aiming-for-idiomatic-rust) — Discusses different ways to solve a popular coding puzzle, 'balanced brackets', in Rust.\n  - [Naming Your Lifetimes](https://www.possiblerust.com/pattern/naming-your-lifetimes) — Explains how using longer, declarative lifetime names can help to disambiguate which borrow is which.\n  \n\n### 2020\n\n- [Are out parameters idiomatic in Rust?](https://steveklabnik.com/writing/are-out-parameters-idiomatic-in-rust) — Discusses the pros and cons of functions returning a value vs. modifying a parameter in-place.\n  - [Guide on how to write documentation for a Rust crate](https://blog.guillaume-gomez.fr/articles/2020-03-12+Guide+on+how+to+write+documentation+for+a+Rust+crate) — Writing good documentation with rustdoc including many examples.\n  - [Learning Rust through open source and live code reviews](https://loige.co/learning-rust-through-open-source-and-live-code-reviews/) — Covers patterns like 'FromStr' and exposing a CLI and a library in one crate.\n  - [Refactoring Rust Transpiled from C](https://immunant.com/blog/2020/09/transpiled_c_safety/) — Describes how to lift a C-project that was automatically converted to unsafe Rust to safer, more idiomatic Rust.\n  - [Context-preserving error handling](https://kazlauskas.me/entries/errors) — Explains how to use crates like 'thiserror' in combination with 'map_err' to add context to errors.\n  \n\n### 2019\n\n- [Rust Patterns: Enums Instead Of Booleans](http://blakesmith.me/2019/05/07/rust-patterns-enums-instead-of-booleans.html) — Discusses how using enums instead of booleans can express intent more clearly in Rust.\n  - [Taking string arguments in Rust](http://xion.io/post/code/rust-string-args.html) — Discussing how to avoid subtle issues with string handling and when to use 'str' vs 'String'.\n  - [Await a minute](https://docs.rs/dtolnay/0.0.3/dtolnay/macro._01__await_a_minute.html) — Example code for moving from raw futures to async/await syntax to improve error handling.\n  \n\n### 2018\n\n- [Programming an ARM microcontroller in Rust at four different levels of abstraction](https://pramode.in/2018/02/20/programming-a-microcontroller-in-rust-at-four-levels-of-abstraction/) — Demonstrates how Rust helps to move from low-level embedded code to high-level abstractions.\n  \n\n### 2017\n\n- [The balance between cost, useability and soundness in C bindings, and Rust-SDL2's release](https://web.archive.org/web/20190509123207/https://cobrand.github.io/rust/sdl2/2017/05/07/the-balance-between-soundness-cost-useability.html) — Writing safe, sound, idiomatic libraries despite the limitations of the borrow checker.\n  - [Math with distances in Rust: safety and correctness across units](https://ferrisellis.com/content/rust-implementing-units-for-types/) — How to create a system to cleanly and safely do arithmetic with lengths.\n  - [Lessons learned redesigning and refactoring a Rust Library](https://web.archive.org/web/20220126172949/https://blog.mgattozzi.dev/refactor-rust/) — 'RefCell', the builder pattern and more.\n  - [Iteration patterns for Result \u0026 Option](http://xion.io/post/code/rust-iter-patterns.html) — Explores how to filter and partition iterators of Result and Option types idiomatically.\n  \n\n### 2016\n\n- [Idiomatic tree and graph like structures in Rust](https://rust-leipzig.github.io/architecture/2016/12/20/idiomatic-trees-in-rust/) — Introduction to safe, dynamic, arena based tree structures without using lifetimes.\n  - [Convenient and idiomatic conversions in Rust](https://ricardomartins.cc/2016/08/03/convenient_and_idiomatic_conversions_in_rust) — Explains 'From\u003cT\u003e', 'Into\u003cT\u003e', 'TryFrom\u003cT\u003e', 'TryInto\u003cT\u003e', 'AsRef\u003cT\u003e' and 'AsMut\u003cT\u003e' with practical examples.\n  - [Rustic Bits](https://llogiq.github.io/2016/02/11/rustic.html) — Small things that make for rustic code.\n  - [Ripgrep Code Review](https://blog.mbrt.dev/posts/ripgrep/) — An analysis of the popular 'ripgrep' tool's source code.\n  - [Pretty State Machine Patterns in Rust](https://hoverbear.org/2016/10/12/rust-state-machine-pattern/) — How to represent a State Machine in an expressive and understandable way in Rust.\n  - [Teaching libraries through good documentation](https://deterministic.space/teaching-libraries.html) — How to use the full power of Rust's documentation support (e.g. doc tests).\n  - [Elegant Library APIs in Rust](https://deterministic.space/elegant-apis-in-rust.html) — Many helpful tips and tricks for writing libraries in Rust.\n  - [Russian Dolls and clean Rust code](https://web.archive.org/web/20220126183049/https://blog.mgattozzi.dev/russian-dolls/) — How to use the full power of 'Option' and 'Result' (especially 'and_then()' and 'unwrap_or()').\n  \n\n### 2015\n\n- [Rayon: data parallelism in Rust](https://smallcultfollowing.com/babysteps/blog/2015/12/18/rayon-data-parallelism-in-rust/) — Writing elegant parallel code in Rust.\n  - [Strategies for solving 'cannot move out of' borrowing errors in Rust](https://hermanradtke.com/2015/06/09/strategies-for-solving-cannot-move-out-of-borrowing-errors-in-rust.html) — Practical tips to help understand the borrow-checker and move semantics.\n  - [Effectively Using Iterators In Rust](https://hermanradtke.com/2015/06/22/effectively-using-iterators-in-rust.html) — Explanation of the 'Iter' and 'IntoIter' traits and how loops actually work in Rust.\n  - [Creating a Rust function that returns a \u0026str or String](https://hermanradtke.com/2015/05/29/creating-a-rust-function-that-returns-string-or-str.html) — How 'Into' and 'Cow' (Clone-on-write) work together to avoid allocations for string types.\n  - [Creating a Rust function that accepts String or \u0026str](https://hermanradtke.com/2015/05/06/creating-a-rust-function-that-accepts-string-or-str.html) — How to make calling your code both ergonomic and fast (zero-allocation).\n  - [Error Handling in Rust](https://blog.burntsushi.net/rust-error-handling/) — Understanding and handling errors in Rust in an idiomatic way.\n  - [Rust traits for developer friendly libraries](https://benashford.github.io/blog/2015/05/24/rust-traits-for-developer-friendly-libraries/) — Thoughts about implementing good Rust libraries.\n  \n\n## 🎤 Talks\n\n\n\n### 2024\n\n- The Four Horsemen of Bad Rust Code — A talk about common pitfalls in Rust code like overengineering and premature optimization. [[Video](https://github.com/corrode/four-horsemen-talk)]\n  \n\n### 2023\n\n- Tricks of the Trait: Enabling Ergonomic Extractors — Rust Nation UK, Feb. 2023 [[Video](https://www.youtube.com/watch?v=7DOYtnCXucw)]\n  \n\n### 2022\n\n- Ergonomic APIs for hard problems — RustLab Conference, October 2022 [[Video](https://www.youtube.com/watch?v=Phk0C-kLlho)]\n  - Nine Rules for Elegant Rust Library APIs — Seattle Rust Meetup, Sep. 2022 [[Video](https://www.youtube.com/watch?v=6-8-9ZV-2WQ)]\n  \n\n### 2020\n\n- Macros for a More Productive Rust — RustConf 2020 [[Video](https://www.youtube.com/watch?v=dZiWkbnaQe8)]\n  \n\n### 2019\n\n- Making Rust Delightful — RustCon Asia 2019 [[Video](https://www.youtube.com/watch?v=YSEx8wtlPWc)]\n  \n\n### 2018\n\n- Idiomatic Rust - Writing Concise and Elegant Rust Code — FOSDEM 2018 [[Video](https://www.youtube.com/watch?v=P2mooqNMxMs)]\n  \n\n### 2017\n\n- Idiomatic Rust Libraries — Rustfest Kiev [[Video](https://www.youtube.com/watch?v=0zOg8_B71gE)]\n  \n\n## 💬 Forum\n\n\n\n### 2020\n\n- [Preferred way of passing `Path`-like types around?](https://www.reddit.com/r/rust/comments/cekeq9/preferred_way_of_passing_pathlike_types_around/)\n  \n\n### 2017\n\n- [An idiomatic way to sum up values in a multidimensional Array](https://users.rust-lang.org/t/an-idiomatic-way-to-sum-up-values-in-a-multidimensional-array/9485)\n  - [Which is more idiomatic? Functional, imperative or a mix?](https://users.rust-lang.org/t/which-is-more-idiomatic-functional-imperative-or-a-mix/11278)\n  \n\n## 📜 History\n\nComing from Python, I loved the guidelines on how _idiomatic Python_ looks like. I was inspired by the likes of Peter Norvig, who wrote amazing articles on [spellcheckers](https://norvig.com/spell-correct.html) and [sudoku solvers](https://norvig.com/sudoku.html); and, of course, the [Zen of Python](https://www.python.org/dev/peps/pep-0020/). For Rust, there is no such thing as the Zen of Python, however, so I started collecting my own resources.\nThe goal of this project is to create a peer-reviewed collection of articles/talks/repos, which teach idiomatic Rust style. It's a community project and you can contribute.\n\n## 🔏 License\n\n[![CC0](https://i.creativecommons.org/p/zero/1.0/88x31.png)](https://creativecommons.org/publicdomain/zero/1.0/)\n\nTo the extent possible under law, [Matthias Endler](https://endler.dev) has waived all copyright and related or neighboring rights to this work.\nLogo adapted from [FreePik.com](https://www.freepik.com).","funding_links":["https://github.com/sponsors/mre"],"categories":["Resources","Rust","Technical","Others","资源 Resources","资源","Rust 程序设计","Resource for References:","\u003ca name=\"Rust\"\u003e\u003c/a\u003eRust"],"sub_categories":["Web programming","Peripherals","网络编程 Web programming","网页编程","网络服务_其他","Rust learning","web编程 Web programming"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmre%2Fidiomatic-rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmre%2Fidiomatic-rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmre%2Fidiomatic-rust/lists"}