You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Go to file
simonsan dfd74a86d1
Adding some additional resources (#159)
4 years ago
.github/workflows Add markdownlint to CI (#164) 4 years ago
anti_patterns Add markdownlint to CI (#164) 4 years ago
functional Table alignment in functional/index.md (#152) 4 years ago
idioms Several FFI Sections: Strings, Errors, and API Design (#106) 4 years ago
patterns Adding informative links to Builder pattern (#158) 4 years ago
refactoring Apply markdownlint to project (#163) 4 years ago
.env Updating mdbook (#162) 4 years ago
.gitignore Adding mdbook configuration and deployment to gh-pages (#111) 4 years ago
.markdownlint.yaml Apply markdownlint to project (#163) 4 years ago
CONTRIBUTING.md Writing an introduction for the contribution guide (#161) 4 years ago
LICENSE Initial commit 9 years ago
README.md Several FFI Sections: Strings, Errors, and API Design (#106) 4 years ago
SUMMARY.md Add participation to Introduction (#160) 4 years ago
additional_resources.md Adding some additional resources (#159) 4 years ago
book.toml Adding mdbook configuration and deployment to gh-pages (#111) 4 years ago
intro.md Add participation to Introduction (#160) 4 years ago
template.md Apply markdownlint to project (#163) 4 years ago

README.md

Rust Design Patterns

An open source book about design patterns and idioms in the Rust programming language that you can read here.

TODOs

Idioms

  • TODO stability for extensibility
  • TODO trait to separate visibility of methods from visibility of data (https://github.com/sfackler/rust-postgres/blob/v0.9.6/src/lib.rs#L1400)
  • TODO leak amplification ("Vec::drain sets the Vec's len to 0 prematurely so that mem::forgetting Drain "only" mem::forgets more stuff. instead of exposing uninitialized memory or having to update the len on every iteration")
  • TODO interior mutability - UnsafeCell, Cell, RefCell

Design patterns

Anti-patterns

  • TODO thread + catch_panic for exceptions
  • TODO Clone to satisfy the borrow checker
  • TODO Matching all fields of a struct (back compat)
  • TODO wildcard matches
  • TODO taking an enum rather than having multiple functions
  • TODO unwrap()ing every Result instead of forwarding it

Contributing

You are missing content in this repository that can be helpful for others and you are eager to explain it? Awesome! We are always happy about new contributions (e.g. elaboration or corrections on certain topics) to this project.

We suggest reading our Contribution guide to get more information on how it works.

Building with mdbook

This book is built with mdbook. You can install it by running cargo install mdbook.

If you want to build it locally you can run one of these two commands in the root directory of the repository:

  • mdbook build

    Builds static html pages as output and place them in the /book directory by default.

  • mdbook serve

    Serves the book at http://localhost:3000 (port is changeable, take a look at the terminal output to be sure) and reloads the browser when a change occurs.

License

This content of this repository is licensed under MPL-2.0; see LICENSE.