Rust Language Cheat Sheet

Overview

Logo Rust Language Cheat Sheet

Read Online Cached PDF

A single-page Rust resource for people who like high information density.

Use cases, in order of priority:

  • identification & lookup guide for constructs encountered in code,
  • discover parts of the language you might not know,
  • learn about Rust if you have prior programming experience.

Building

Built with Zola, the static site generator written in Rust. To develop locally install Zola, then run:

zola serve

Contributing

Contributions are welcome and you can PR bug fixes directly. If you somehow ended up here but prefer not to use Github write to [email protected], or use the on-site buttons.

Constructive feedback would be most actionable, but if you just want to vent your frustration that's fine too :)

Credits

Big shout-out to all the contributors and people filing issues and pull requests for being awesome!

Also:

Legal & License

Please see here for details.

Comments
  • gh action to generate release

    gh action to generate release

    resolves #91

    Added basic github action to generate a PDF and create a release. We could do some fine tuning now, for example on the generated PDF.

    Current status includes:

    • Dockerfile (+ build script)
    • gh action to
      • build and run docker image
      • create release and upload pdf

    Example of action run. Example of generated release PDF 2020-10-21-213802.

    Running the actions takes between 60s - 70s.

    opened by johannst 9
  • Suggestions to improve

    Suggestions to improve "Custom Types" visualizatiaton

    While great overall, there are some aspects i think could be made more clearer https://cheats.rs/#custom-types

    • [ ] What is the T: !Sized example with the arrow trying to show?
    • [ ] Does the grey border take up space? In other word: has struct S; a size? If not: is it big?

    Maybe the space within the struct (especially the padding) could be made more clearer using grey boxes within those grey borders?

    I think this way we could make more clear whether the tuple (A, B, C) and the struct S { a: A, b: B, c: C} have the same size or not.

    type: content type: design 
    opened by kud1ing 8
  • suggestion: note about Cargo.lock and git

    suggestion: note about Cargo.lock and git

    I'm not sure if this is worthy of inclusion but I've had multiple times where I forgot and had to look up if I should or shouldn't commit Cargo.lock for bins and libs.

    It might be worth adding a note somewhere that mentions that Cargo.lock should be version controlled for bins and not for libs so that people can easily find the rule when they forget it. cargo new --lib adds it to the .gitignore file by default, so this may be an issue most people don't worry about, I'll leave it up to you to determine if it should be included.

    type: content needs-discussion 
    opened by yaahc 8
  • Add references to RFCs defining good documentation practices

    Add references to RFCs defining good documentation practices

    In these RFCs, great details and example are given about the right way to do documentation. I’m not sure if this is worth being detailed on cheats.rs, but a link is a way as good as another to find these documents.

    In particular, these RFC are way more detailed than the Reference book.

    See Rust-lang Contributing.md for a proof that RFC1574 is used for std.

    opened by cljoly 8
  • Suggestion: section about iteration/iterators

    Suggestion: section about iteration/iterators

    https://stackoverflow.com/questions/34733811/what-is-the-difference-between-iter-and-into-iter

    An "Iteration" section could give an overview over:

    Tasks:

    • iterate over references: as_ref()
    • iterate over mutable references
    • iterate and consume

    Traits/methods:

    type: content 
    opened by kud1ing 7
  • suggestion: proc macro section

    suggestion: proc macro section

    I can't seem to find any information about proc macros in cheats.rs. I feel like this is a relatively important part of the rust ecosystem and it deserves a section. Particularly with syn and quote just hitting their 1.0.0 releases, it seems like a good time to bring in some documentation for them.

    I'd be happy to add one myself as a PR but I don't know proc macros well yet so it will have to wait until after I take the time to properly learn them.

    type: content needs-discussion postponed 
    opened by yaahc 7
  • "Hardcoded magic"

    From Reddit:

    Next to the “invisible sugar” perhaps also provide ”hardcoded magic” for traits and other stuff that “seems” like a normal library item, but cannot be reimplemented by the user in terms of other items. For example, the traits “Copy”, “Clone”, “Deref”, etc.

    type: content 
    opened by ralfbiedert 6
  • Printed Output Has Significant Flaws

    Printed Output Has Significant Flaws

    I've noticed that the site redesign has caused serious breakages in both the print and cached PDF output.

    • The noprint class on the "Fork Me on GitHub ribbon" has no effect.
    • Entire sections of the reference which I'd want to print are hidden inside <noprint> elements.
    • Tab widgets which do print are not unrolled, denying access to all but their default tabs.
    • Expandable explanations in the memory diagrams print collapsed.
    • If I turn off noprint to access the stuff I want, bits of your diagrams show up in the top-left of page 1 in print mode. (Honestly, I'd suggest using inline SVG for those rather than abusing things like position: absolute and <table> to do illustration.)
    • If I uncollapse the tab widgets the most obvious way, they overdraw the next section down.

    This is how far I got to make a userscript to turn it into desired printable output before I got fed up with how seemingly ordinary tweaks caused strange breakages in the print preview, where the DOM Inspector is very crippled:

    /* Stuff that got applied to things I want printed */
    noprint, .noprint {
        display: block !important;
    }
    tabs > tab > panel {
        display: inline !important;
    }
    explanation { 
        display: inherit !important;
    }
    
    /* Hacks to fix 'diagram is shoved to the top-left corner of page 1' bugs 
       revealed by turning off noprint. */
    
    #custom-types + p + datum { position: relative !important; }
    #custom-types + p + datum > .hidden { position: relative !important; }
    
    datum[style='margin-right:70px'] { position: relative !important; }
    datum[style='margin-right:70px'] code { white-space: nowrap !important; }
    
    datum.spaced[style='padding-bottom:165px'] memory-entry { 
        position: relative !important; 
    }
    datum.spaced[style='padding-bottom:165px'] visual { 
        margin-right: 10em;
    }
    
    /* Stuff that shouldn't be printed but is (or would be after my tweaks) */
    body > div:first-child > a.noprint:first-child { 
        /* Hide the GitHub ribbon that isn't hiding properly */
        display: none !important;
    }
    page-controls, #helloctrl, subtext::after, tabs.lifetimes + footnotes {
        display: none !important;
    }
    

    Overall, with the bits like the diagrams and the tab widget unrolling, it feels like I'm reverse-engineering your attempts to fight the CSS layout model instead of working with it.

    type: design 
    opened by ssokolow 5
  • Confusing statement.

    Confusing statement.

    In the "Strength" section of the "Hello Rust" it says:

    can avoid 70% of all (memory-related) safety issues present in C / C++

    This sounds like Rust can avoid 70% of memory-related issues, and can not handle 30% of memory-related issues. Maybe it should be reworded. Here is a suggestion (I'm not a native speaker): "can avoid memory-related safety issues (memory-related issues are 70% of all safety issues)"

    opened by hojjatabdollahi 5
  • Nightly mode is too dark

    Nightly mode is too dark

    If you look at how other sites or apps implement dark / nightly mode, you will almost never find full black backgrounds (except in "OLED dark" themes bc. OLED screens can just completely turn off pixels that are showing full black).

    When toggling the dark mode on cheat.rs the background immediately caught my eye as uncommonly dark. Would you consider switching to a dark grey instead?

    See also Never use Black.

    opened by jplatte 5
  • PDF should be created automatically via Github Action

    PDF should be created automatically via Github Action

    As discussed in #90, it would be nice if a (Docker) PDF action ran automatically and updated the releases. The ideal solution:

    • Builds the page Docker-locally via Zola (preferred), or just grabs the latest released one
    • Generates a portrait(?) PDF preserving background colors but w/o user visible "corner" metadata as some browsers do
    • Publishes the PDF as a new release
    • Generally works without modifying the repository
    type: infrastructure help-wanted 
    opened by ralfbiedert 5
  • Bit wise operations missing?

    Bit wise operations missing?

    I'm a bit new to rust and I encountered the symbol << which I wanted to know what does it mean and I didn't found it on the website. It'd be great if it was added in a proper location, with a link to here:

    https://doc.rust-lang.org/stable/std/ops/trait.Shr.html

    Thanks a lot for maintaining this website.

    type: content help-wanted 
    opened by doronbehar 5
  • EPUB version of Rust cheat sheet

    EPUB version of Rust cheat sheet

    I think it would be useful to create a ePUB version of the Rust cheat sheet? That would be more readable in small screens, as in a smartphone, or tablets.

    type: infrastructure help-wanted 
    opened by oscaretu 8
  • FFI Chapter

    FFI Chapter

    Suggested via mail:

    • C-FFI chapter (e.g., Rust MVP to / from C)
    • Maybe even examples showing other languages (C#, Python, Java, ...)
    • repr(C), no_mangle, ...
    • Rust string conversion to / from char*
    • ...
    type: content needs-discussion suggested-via-site 
    opened by ralfbiedert 0
Owner
Ralf Biedert
Principal Engineer. Working on VR, AR, eye tracking, mostly in Rust.
Ralf Biedert
a cheat-sheet for mathematical notation in Rust 🦀 code form

math-as-rust ?? Based on math-as-code This is a reference to ease developers into mathematical notation by showing comparisons with Rust code.

Eduardo Pereira 13 Jan 4, 2023
Rust Concurrency Cheat Sheet

Rust ensures data race safety through the type system (Send and Sync marker traits) as well as the ownership and borrowing rules: it is not allowed to alias a mutable reference, so it is not possible to perform a data race.

null 327 Dec 19, 2022
KVM memory R/W cheat for CSGO

CSGO KVM DMA Main Feature Triggerbot with random press/release time *TODO list: add method to detect key event in VM. add No recoil. add wallhack(

AtomicBottle 5 Sep 27, 2023
A repository for showcasing my knowledge of the Rust programming language, and continuing to learn the language.

Learning Rust I started learning the Rust programming language before using GitHub, but increased its usage afterwards. I have found it to be a fast a

Sean P. Myrick V19.1.7.2 2 Nov 8, 2022
Nyah is a programming language runtime built for high performance and comes with a scripting language.

?? Nyah ( Unfinished ) Nyah is a programming language runtime built for high performance and comes with a scripting language. ??️ Status Nyah is not c

Stacker 3 Mar 6, 2022
Mewl, program in cats' language; A just-for-fun language

Mewl The programming language of cats' with the taste of lisp ?? What,Why? Well, 2 years ago in 2020, I created a esoteric programming language called

Palash Bauri 14 Oct 23, 2022
lelang programming language is a toy language based on LLVM.

lelang leang是一门使用Rust编写,基于LLVM(inkwell llvm safe binding library)实现的编程语言,起初作为课程实验项目,现在为个人长期维护项目。 Target Features 支持8至64位的整形类型和32/64位浮点 基本的函数定义,调用,声明外部

Aya0wind 5 Sep 4, 2022
The Devils' Programming Language (Quantum Programming Language)

devilslang has roots in Scheme and ML-flavored languages: it's the culmination of everything I expect from a programming language, including the desire to keep everything as minimalistic and concise as possible. At its core, devilslang is lambda-calculus with pattern-matching, structural types, fiber-based concurrency, and syntactic extension.

Devils' Language 2 Aug 26, 2022
Simple autoclicker written in Rust, to learn the Rust language.

RClicker is an autoclicker written in Rust, written to learn more about the Rust programming language. RClicker was was written by me to learn more ab

null 7 Nov 15, 2022
clone of grep cli written in Rust. From Chapter 12 of the Rust Programming Language book

minigrep is a clone of the grep cli in rust Minigrep will find a query string in a file. To test it out, clone the project and run cargo run body poem

Raunak Singh 1 Dec 14, 2021
The ray tracer challenge in rust - Repository to follow my development of "The Raytracer Challenge" book by Jamis Buck in the language Rust

The Ray Tracer Challenge This repository contains all the code written, while step by implementing Ray Tracer, based on the book "The Ray Tracer Chall

Jakob Westhoff 54 Dec 25, 2022
The Rust Compiler Collection is a collection of compilers for various languages, written with The Rust Programming Language.

rcc The Rust Compiler Collection is a collection of compilers for various languages, written with The Rust Programming Language. Compilers Language Co

null 2 Jan 17, 2022
Rust Sandbox [code for 15 concepts of Rust language]

Rust-Programming-Tutorial Rust Sandbox [code for 15 concepts of Rust language]. The first time I've been introduced to Rust was on January 2022, you m

Bek Brace 4 Aug 30, 2022
Game Boy Emulator written in Rust, as a way to fully grasp the Rust programming language

Flan's Game Boy Emulator Game Boy Emulator written in Rust, as a way to get hands-on with the Rust programming language, and creating a proper project

Flan 3 Dec 31, 2022
A minimal version of 'grep' implemented in Rust. Exercise in the "The Rust Programming Language" book.

Minigrep - A simple grep-like tool implemented in Rust This simple CLI tool searches for a given pattern in a specified file and as a result, it print

Filip Szutkowski 3 Mar 15, 2024
The Computer Language Benchmarks Game: Rust implementations

The Computer Language Benchmarks Game: Rust implementations This is the version I propose to the The Computer Language Benchmarks Game. For regex-dna,

Guillaume P. 69 Jul 11, 2022
A community curated list of Rust Language streamers

Awesome Rust Streaming This is a community curated list of livestreams about the programming language Rust. Don't see a stream that you like? Feel fre

James Munns 587 Dec 26, 2022
Nixt is an interpreted programming language written in Rust

Nixt Nixt is an interpreted lisp inspired programming language written in Rust Index About Examples Installation Build About Nixt goal is to provide a

Wafelack 17 Jul 18, 2022
a function programming language for real world applications made in rust

a function programming language for real world applications made in rust

Tanay Pingalkar 6 Jun 12, 2022