Closed deepaksirone closed 7 years ago
extern crate rustbox; use rustbox::{Color, RustBox}; use std::char::from_digit; use rustbox::Key; fn main() { let rustbox = RustBox::init(Default::default()).ok().unwrap(); for x in 0..rustbox.width() - 1 { rustbox.print_char(x, 0, rustbox::RB_NORMAL, Color::Black, Color::Cyan, '-'); } for y in 0..rustbox.height() - 1 { rustbox.print_char(0, y + 1, rustbox::RB_NORMAL, Color::Black, Color::Blue, from_digit(y as u32, 10).unwrap()); } loop { rustbox.present(); match rustbox.poll_event(false) { Ok(rustbox::Event::KeyEvent(key)) => { match key { Key::Char('q') => { break; } _ => { } } }, Err(e) => panic!("{}", e), _ => { } } } }
The following program does not print anything to the screen whereas changing the from_digit() call to a hardcoded char value makes it run fine.
Sorry for this one, this is the expected behavior :) from_digit() takes a single digit and not a number. Converting the number to a string solves the issue.
The following program does not print anything to the screen whereas changing the from_digit() call to a hardcoded char value makes it run fine.