Skip to content

Bug: guessing game rand version #4679

@exploreriii

Description

@exploreriii
let secret_number = rand::thread_rng().gen_range(1..=100);

this example generates an error using modern rand versions

it passes using rand 0.8

Image

Part of this example:

use std::io;

use rand::Rng;

fn main() {
    println!("Guess the number!");

    let secret_number = rand::thread_rng().gen_range(1..=100);

    println!("The secret number is: {secret_number}");

    println!("Please input your guess.");

    let mut guess = String::new();

    io::stdin()
        .read_line(&mut guess)
        .expect("Failed to read line");

    println!("You guessed: {guess}");
}

https://doc.rust-lang.org/book/ch02-00-guessing-game-tutorial.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions