Giter VIP home page Giter VIP logo

ad-si / rust-flashcards Goto Github PK

View Code? Open in Web Editor NEW
472.0 8.0 13.0 4.76 MB

Over 550 flashcards to learn Rust from first principles. Written in markdown with script to convert them to an Anki deck or PDF file.

Home Page: https://ankiweb.net/shared/info/1541471942

Nix 10.30% Makefile 4.08% Rust 85.62%
anki anki-cards anki-deck anki-flashcards deck flashcard learn learning rust education

rust-flashcards's Introduction

Rust Flashcards

Over 550 flashcards to learn Rust from first principles.

Screenshot of Anki showing a Rust flashcard


The cards are written in markdown and based on the official Rust Book.

Either get the Anki deck directly from AnkiWeb - Rust Flashcards or download the latest version from the releases page.

Credit to u/WebDev193 for doing the initial grunt work.

Development

Run nix develop to enter the development environment with Anki Panky and Pandoc installed.

Then run following makefile targets to build the artifacts:

  • make cards.apkg to generate the Anki deck
  • make cards.pdf to generate the PDF file

rust-flashcards's People

Contributors

ad-si avatar xiaoxiangxianzi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

rust-flashcards's Issues

Invalid answer/question in PDF page 180-182

PDF page 180 ("What's a possible error inducing operation on string slice range indices?"), I'm not sure what the first_word function is supposed to be:

  1. It returns a usize, not a slice, even though that area of the deck is about slices,
  2. If it's supposed to show a problem with slicing in between UTF-8 character, b' ' is a single byte character, so it's valid to slice at that boundary (it would be invalid if item was in the range 0x80-0xBF, i.e. of the form 0x10xxxxxx)
  3. If it's the beginning of the page 181 question, then it's at the wrong place (but then also see next point of this issue)

page 181/182:
It mentions a first_word function, but if the function from page 180, then see point 1 above, which does compile since word is then the usize 5, and not a reference to the "hello" slice.

Some cards are truncated in the PDF

Some cards are truncated in the PDF.

Some examples:

  • Page 110 (loop labels), where the code is truncated but one could think it's just
  • Page 114 ("Looping through a collection like this is a bad idea. Give 2 reasons why.") only shows the first part of the detailed explanation ("error prone") and not the 2nd ("slow").
  • Page 116 ("What is a better and more concise alternative to loop over the array?"), missing the last sentence ("The safety and conciseness of for loops ...")
  • Page 128 ("What happens in terms of the heap and stack when we assign s1 to s2 in line 2?") only show part of the "s1" variable and nothing of "s2" or the heap.
  • ...

Card "What's a workaround we can use to allow multiple mutable references to the same data?"

Current answer

We can use curly brackets to create a new scope, allowing for multiple mutable references, just not simultaneous ones:

fn main() {
  let mut s: String = String::from("Hello");
  {
    let r1: &mut String = &mut s;
    // r1 goes out of scope here,
  }
  // So we can make a new reference with no problems
  let r2: &mut String = &mut s;
}

Proposal

I think this answer is not correct. In fact thanks to NLL the above code works without curly braces too (https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=6b2144aeb8d82883ec17cb94af60c888).

At first, I would have answered to use a Mutex. So I'm not sure how to update this card.

  1. Remove it
  2. Use an example that does not compile, for instance the one at the end of https://blog.rust-lang.org/2022/08/05/nll-by-default.html, but here the solution is not about adding curly braces
  3. Update the question to point to a Mutex answer

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.