You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use rand::Rng;use std::cmp::Ordering;use std::io;fnmain(){println!("Guess the number!");let secret_number = rand::thread_rng().gen_range(1..=100);println!("eew{}",&secret_number);// loop {println!("Please input your guess.");letmut guess = String::new();
io::stdin().read_line(&mut guess).expect("Failed to read line");let guess:u32 = guess.trim().parse().expect("error");println!("You guessed: {guess}");match guess.cmp(&secret_number){Ordering::Less => println!("Too small!"),Ordering::Greater => println!("Too big!"),Ordering::Equal => {println!("You win!");// break;}}// }}
SCREEN:
FULL LOGS
-------------------------------------------------------------------
You may only use the C/C++ Extension for Visual Studio Code
with Visual Studio Code, Visual Studio or Visual Studio for Mac
software to help you develop and test your applications.
-------------------------------------------------------------------
Loaded 'C:\Users\Tester\projects\guessing_game\target\debug\guessing_game.exe'.
Loaded 'C:\Windows\System32\ntdll.dll'.
Loaded 'C:\Windows\System32\kernel32.dll'.
Loaded 'C:\Windows\System32\KernelBase.dll'.
Loaded 'C:\Windows\System32\advapi32.dll'.
Loaded 'C:\Windows\System32\msvcrt.dll'.
Loaded 'C:\Windows\System32\sechost.dll'.
Loaded 'C:\Windows\System32\rpcrt4.dll'.
Loaded 'C:\Windows\System32\ws2_32.dll'.
Loaded 'C:\Windows\System32\bcrypt.dll'.
Loaded 'C:\Windows\System32\userenv.dll'.
Loaded 'C:\Windows\System32\ucrtbase.dll'.
Loaded 'C:\Windows\System32\cryptbase.dll'.
Guess the number!
Loaded 'C:\Windows\System32\bcryptprimitives.dll'.
eew32
Please input your guess.
thread 'main' panicked at 'error: ParseIntError { kind: Empty }', src\main.rs:20:47
stack backtrace:
Loaded 'C:\Windows\System32\dbghelp.dll'.
Loaded 'C:\Windows\System32\combase.dll'.
Loaded 'C:\Windows\System32\oleaut32.dll'.
Loaded 'C:\Windows\System32\msvcp_win.dll'.
0: rust_begin_unwind
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library\std\src/panicking.rs:575:5
1: core::panicking::panic_fmt
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library\core\src/panicking.rs:64:14
2: core::result::unwrap_failed
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library\core\src/result.rs:1790:5
3: core::result::Result<T,E>::expect
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0\library\core\src/result.rs:1069:23
4: guessing_game::main
at .\src\main.rs:20:26
5: core::ops::function::FnOnce::call_once
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0\library\core\src\ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Exception thrown at 0x00007FFFB4F0FE7C (KernelBase.dll) in guessing_game.exe: 0x20474343 (parameters: 0x0000000000D33440).
Exception thrown at 0x00007FFFB4F0FE7C (KernelBase.dll) in guessing_game.exe: 0x21474343 (parameters: 0x0000000000D33440, 0x0000000000C3F670, 0x0000000000487C88, 0x0000000000000000).
Exception thrown at 0x00007FFFB4F0FE7C (KernelBase.dll) in guessing_game.exe: 0x21474343 (parameters: 0x0000000000D33440, 0x0000000000C3F860, 0x0000000000402E9E, 0x0000000000000000).
Exception thrown at 0x00007FFFB4F0FE7C (KernelBase.dll) in guessing_game.exe: 0x21474343 (parameters: 0x0000000000D33440, 0x0000000000C3F8F0, 0x000000000040226B, 0x0000000000000000).
The program '[35452] guessing_game.exe' has exited with code 101 (0x65).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Click on
Run
works, ButDebug
produces error.Guessing game from rust book:
SCREEN:
FULL LOGS
ENV:
vscode v1.77.0 | windows 11 | rust 1.68.2
Beta Was this translation helpful? Give feedback.
All reactions