Bad Example
To print variables within a string, you can use{}
as a placeholder for the variable, and then pass its value as an argument. You can also use multiple placeholders, just remember to supply all the arguments in order.
This block introduces two concepts at once: placeholders, and the fact that
multiple placeholders can be used.
Good Example
When split into two blocks, this is easier to understand.
To print variables within a string, you can use{}
as a placeholder for the variable, and then pass its value as an argument.
You can also use multiple placeholders, just remember to supply all the arguments in order.
Exceptions
Nested/Auxiliary Content
It’s probably okay to break this rule if you’re introducing auxiliary information that isn’t core to the concept at hand. For example, if you’re working on a “Rust Data Types” concept that covers Strings, Integers, Floats and other data types, it’s probably okay to have a block like this that expands on different integer types:Integer types Examples includeAlthough this block could be broken down into one for signed integers and another for unsigned integers, it’s probably not worth it. The concept covers multiple data types, and the block is just expanding on one of them. If this block was in a concept that was solely about integers, it’d probably make sense to split up.i32
,u32
,i64
, andu64
. The name of each type gives hints about its features.The number at the end like 32 or 64 tells us how much space it uses in memory.
i32
andi64
and such have an i, meaning they’re signed. This means they can be negative, zero, or positive.u32
andu64
and others have a u, showing they’re unsigned. They can only be zero or positive.