Live data from Hacker News

Rust Language Cheat Sheet

cheats.rs

61–65 of 65 posts

Re: Rust Language Cheat Sheet

#61

Earlier quoted context omitted.

This is why I'm glad we have both; I don't think one resource could ever satisfy everyone. Pumped to see Rust in Action getting closer to publication too!

I just bought Rust in Action a couple weeks ago (after having gone up to chapter 11 in the No Starch book). It's definitely good to have both. I'll probably do 1/2 the new book, finish the 1st one and then finish the new one. I did pretty much the same thing with Dave Thomas's Programming Elixir book, bailing halfway through, using a 2nd resource to consolidate, and then returning to finish it. I like learning Rust s…

This is a common issue. You don’t have to go low level; you can build anything, including web apps.

Re: Rust Language Cheat Sheet

#62

Earlier quoted context omitted.

Oh, my! I have spend countless hours on the web looking for (and successfully finding, of course) cheat sheets for all sorts of languages, but somehow I had never come across this site. This is extremely well done. Thank you,spectramax, for basically revolutionizing my life this morning! :)

Surprisingly, https://learnxinyminutes.com/docs/bash/ is the best resource out there to learn shell scripting. This page basically turned me from a novice who could only write two commands with | or && between them to a competent shell programmer. My shell scripts have functions, descriptive variables, error handling, good formatting, etc.

I find shellcheck to be really great to go to the step beyound. It find a lot of things that make most shell script brittle and teach you some best practice.

Add shfmt on top and you are good to go.

Re: Rust Language Cheat Sheet

#63

Ralf Biedert, thanks so much for this! I've been learning Rust via the Rust Book for the past few months and this will help so, so much - fantastic work.

I know everyone says how good Rust's documentation is but I tried learning Rust with The Rust Book and found it frustrating: too long and wordy on the easy bits and without useful insight on the hard bits. I ended up buying Programming Rust by Jim Blandy [0] on a recommendation from HN comments and found it must easier to learn from. I'm already familiar with several other languages, which that book assumes, so your…

> everyone says how good Rust's documentation is

I don't know about everyone else, but when I say that I'm mostly referring to the auto generated documentation you get from Cargo. One of Rust's greatest strengths is having uniform documentation for every project.

Re: Rust Language Cheat Sheet

#64

Earlier quoted context omitted.

> Weird, I thought it was just something like "If it's an expression, use a semicolon otherwise you're returning it". This is a common misconception, but it isn't true. Rust is an expression-oriented language. This means that most things are expressions, and evaluate to some kind of value. However, there are also statements. "Item declarations" (stuff like defining structs, etc) and let statements are the two most co…

TBH I thought it made sense, but I'm still confused on everyone elses description lol. I feel like what you said is what I said, but with more accuracy and depth. Eg, if my block was: { foo(); bar() baz(); } My statement holds true, no? It's obviously a syntax problem, since I'm trying to define a statement after I define an expression (which would be trying to execute code after a return, effectively) . So.. I'm not…

I think it is better to not think of ; (or lack of ;) as an "active" return: it isn't like the `return` keyword.

If the last statement/expression in a block is an expression not followed by ;, the block evaluates to that expression. Otherwise (such as, the last expression has a ;), the block evaluates to ().

The function "return" behaviour is because function bodies are blocks: a function returns the value of its block (or any `return`).

Re: Rust Language Cheat Sheet

#65

Earlier quoted context omitted.

You’re not alone. I found the Rust book very hard going, whereas Programming Rust was just the right amount of rigor and interesting examples for me.

This is why I'm glad we have both; I don't think one resource could ever satisfy everyone. Pumped to see Rust in Action getting closer to publication too!

Ah, awesome, another Rust book. I'll keep an eye out for it.

Thanks!

Post reply on HN