Hey so I'm really new to rust and programming at large and I'm having some issues I haven't encountered before. I'm attempting to return the results of user input variables to the screen outside of nesting but I haven't seemed to have any luck.
use std::{thread, time::Duration};
fn main(){
let mut modifer = 0;
let mut ModValue=0;
let mut ModReason = "";
let Y = "Y";
let y = "y";
let N = "N";
let n = "n";
print!("{esc}c", esc = 27 as char);
let mut ModYN = String::new();
println!("Are there any modifiers (Y/N)");
std::io::stdin().read_line(&mut ModYN).unwrap();
let ModYN = ModYN.trim();
if ModYN == y || ModYN == Y{
ModValue = 1;
print!("{esc}c", esc = 27 as char);
let mut modifer:f32=0.0;
let mut input = String::new();
//I'm attempting to get the input from the user to define a modifer reason and value
println!("Please enter the modifer: ");
std::io::stdin().read_line(&mut input).expect("Not a valid string");
modifer = input.trim().parse().expect("Not a valid number");
let mut ModReason = String::new();
println!("Whats the modifer reason: ");
std::io::stdin().read_line(&mut ModReason).unwrap();
let ModReason = ModReason.trim();
}
//Then print those results to the screen outside of nesting
print!("{esc}c", esc = 27 as char);
println!("-Modifer-");
println!("{}",&mut modifer);
println!("-Modifer Reason-");
println!("{}",&mut ModReason);
thread::sleep(Duration::from_secs(5));
}
I've attempted a variety of things; from assigning it as a mutable or borrowing the variable itself to even extending the nesting past the print results. But I've hit a brick wall and could really use some help.