Skip to content

Update of hello-world example for Rust 2018 #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 10 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,36 +30,26 @@ git = "https://github.com/gchp/rustbox.git"
Then, in your `src/example.rs`:

```rust
extern crate rustbox;

use std::error::Error;
use std::default::Default;

use rustbox::{Color, RustBox};
use rustbox::Key;
use rustbox::{self, Color, RustBox, Key};

fn main() {
let rustbox = match RustBox::init(Default::default()) {
Result::Ok(v) => v,
Result::Err(e) => panic!("{}", e),
};
fn main() -> Result<(), Box<Error>> {
let rustbox = RustBox::init(Default::default())?;

rustbox.print(1, 1, rustbox::RB_BOLD, Color::White, Color::Black, "Hello, world!");
rustbox.print(1, 3, rustbox::RB_BOLD, Color::White, Color::Black,
"Press 'q' to quit.");
rustbox.print(1, 3, rustbox::RB_BOLD, Color::White, Color::Black, "Press 'q' to quit.");
rustbox.present();

loop {
match rustbox.poll_event(false) {
Ok(rustbox::Event::KeyEvent(key)) => {
match key {
Key::Char('q') => { break; }
_ => { }
}
},
Err(e) => panic!("{}", e.description()),
_ => { }
match rustbox.poll_event(false)? {
rustbox::Event::KeyEvent(Key::Char('q')) => { break; },
_ => { },
}
}

Ok(())
}
```

Expand Down