How it works...

In this recipe, we print a random number from a range provided by the developer, which in our case is a value between 0 and 10; we use the rand library for performing this option.

We import the rand library with the extern crate command and use the rand::rng module that provides us with the gen_range method. The gen_range method takes two arguments as input that are lower and higher bound values of the range in which it is supposed to predict a random number. In the case of interchanging the position, it would panic.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.17.18