Bawię się Rust i przeniosłem kody źródłowe w tym języku napisane w Intellij do drugiego systemu w którym jest PyCharm. IDE mają zainstalowaną wtyczkę Rust. Pod Intellij tworzyłem te programy w rustup i Rust w wersji 1.41, w drugim systemie na początku nie było rustup tylko samo cargo i rustc, a Rust w wersji 1.43. Ale niektóre programy pomimo swej prostoty nie chciały się już skompilować. Szybko odinstalowałem systemowe cargo i rustc i pobrałem już prawilnie rustup ze strony Rusta. Zaktualizowałem rustup update, ale nie wszystkie programy się kompilują. Teraz nie wiem czy to wina innego IDE, innej wersji Rust, cargo czy rustup?
use std::io;
use std::cmp::Ordering;
use rand::Rng;
pub fn run() {
println!("Zgadnij numer!");
let secret_number = rand::thread_rng().gen_range(1, 101);
loop {
println!("Podaj swoje domysły.");
let mut guess = String::new();
io::stdin().read_line(&mut guess)
.expect("Nie można odczytać linii");
let guess: u32 = match guess.trim().parse() {
Ok(num) => num,
Err(_) => continue,
};
println!("Zgadłeś: {}", guess);
match guess.cmp(&secret_number) {
Ordering::Less => println!("Za mały!"),
Ordering::Greater => println!("Za duży!"),
Ordering::Equal => {
println!("Wygrałeś!");
break;
}
}
}
}
//mod hello;
//mod guess;
//mod value_printing;
//mod random_number;
mod game_numbers;
//mod variables;
//mod shadowing;
//mod floating_point_types;
//mod numeric_operations;
//mod the_boolean_type;
//mod the_character_type;
//mod the_tuple_type;
//mod the_array_type;
//mod functions;
//mod function_parametrs;
//mod expressions;
//mod functions_with_return_values;
//mod function;
fn main() {
//hello::run();
//guess::run();
//value_printing::run();
//random_number::run();
game_numbers::run();
//variables::run();
//shadowing::run();
//floating_point_types::run();
//numeric_operations::run();
//the_boolean_type::run();
//the_character_type::run();
//the_tuple_type::run();
//the_array_type::run();
//functions::run();
//function_parametrs::run();
//expressions::run();
//functions_with_return_values::run();
//function::run();
}