Official guidelines


#1

Hello,

I want to start programmng in Rust but before, is there an official norme / style guide / guidelines like PEP for Python ?
If i’m going to learn Rust, I need to do it correctly and don’t produce code that make a headache at others.

Thanks :slight_smile:


#2

There are the Rust Guidelines by @aturon at https://aturon.github.io/. I also recommend installing rustfmt and using cargo fmt to automatically format code in your projects.

https://crates.io/crates/rustfmt


#3

Thanks !
I had install rustfmt too, pretty nice (cheat) program :slight_smile:


#4

Also use rust-clippy


#5

The Rust Guidelines at https://doc.rust-lang.org/style/ have a more official-looking URL, but otherwise the contents seems to be the same.

(I vaguely remember it to be more up to date than https://aturon.github.io/, but now I can’t find any substantial difference.)


#6

They were imported in-tree, but we recently removed them; check that link
on nightly.


#7

As soon as it doesn’t require nightlies …


#8

I follow a lot of the guidelines of PEP8 and PEP20 and I find my Rust code quite good, if I do say so myself!

Python and Rust have a lot of similarities, in terms of how we like to write code. Explicit over implicit, Forgiveness over permission, etc.