I am just starting to use Rust, under the impression of its ownership paradigm. And reading the tutorial, I found the following code
let secret_number = rand::thread_rng().gen_range(1, 101);
As I assume, a random integer is generated after instantiating of the rand::ThreadRng
structure by calling its method.
Isn't it better for performance simply to use functions like in C? Since Rust positions itself as a system programming language and if I am right in my conjecture, this choice in favor of creating structures and using their methods seems to be quite suboptimal.
Aucun commentaire:
Enregistrer un commentaire