Hi. I'm trying to compile a project to get random number when I get a Char 'N' event.
But I'm getting errors 'unresolved import sys' and 'failed to resolve: maybe a missing crate sys?'.
My code is following:
main.rs
extern crate sys;
use rand::Rng;
use termion::event::{Event, Key};
use srd::io::{stdout, stdin};
fn main() {
let mut rng = rand::thread_rng();
let stdin = stdin();
for evt in stdin.events(){
if evt.unwrap() == Event::Key(Key::Char('N'))){
let dice = rng.gen_range(1..7);
println!("{}", dice);
}
}
}
Cargo.toml
[package]
name = "dice"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rand = "0.8.0"
termion = "1"
sys = "0.0.0"
Additionally, your code makes no reference to it whatsoever, so remove the extern crate line (which is usually not necessary in 2018+ edition), and remove it from your Cargo.Toml and work from there.
After dropping sys crate, fixing the typo mentioned above, fixing the syntax error and following the compiler suggestion to add missing import, code from your initial post compiles. Are you sure you haven't dropped the erroneous part form it?