What is the recommended indentation?

#1

I use 2 spaces in JavaScript, Ruby and Elixir, and 4 spaces in Go. What’s the recommended indentation for Rust?

0 Likes

#2

The standard is 4 spaces.

3 Likes

#3

Thank you! :slight_smile:

0 Likes

#4

You may also want to configure your editor to run rustfmt on save. I find it tremendously freeing to never have to think about style again!

2 Likes

#5

Rely on rustfmt for the recommanded styling

3 Likes

#6

It’s also worth noting that rustfmt has a corresponding style guide, which defines the default/recommended formatting rules.

1 Like