File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -1888,8 +1888,16 @@ fn main() {
18881888
18891889The first thing we changed was to ` use std::rand ` , as the docs
18901890explained. We then added in a ` let ` expression to create a variable binding
1891- named ` secret_number ` , and we printed out its result. Let's try to compile
1892- this using ` cargo build ` :
1891+ named ` secret_number ` , and we printed out its result.
1892+
1893+ Also, you may wonder why we are using ` % ` on the result of ` rand::random() ` .
1894+ This operator is called 'modulo', and it returns the remainder of a division.
1895+ By taking the modulo of the result of ` rand::random() ` , we're limiting the
1896+ values to be between 0 and 99. Then, we add one to the result, making it from 1
1897+ to 100. Using modulo can give you a very, very small bias in the result, but
1898+ for this example, it is not important.
1899+
1900+ Let's try to compile this using ` cargo build ` :
18931901
18941902``` {notrust,no_run}
18951903$ cargo build
You can’t perform that action at this time.
0 commit comments