Skip to content

Commit

Permalink
Merge pull request PistonDevelopers#282 from csherratt/master
Browse files Browse the repository at this point in the history
Use fmt::Display in InitError.
  • Loading branch information
csherratt committed Jan 25, 2015
2 parents 9fe8468 + e7af251 commit 5862e99
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion examples/clipboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extern crate glfw;
use glfw::{Action, Context, Key};

fn main() {
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).ok().expect("Failed to init glfw");
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();

let (mut window, events) = glfw.create_window(300, 300, "Clipboard Test", glfw::WindowMode::Windowed)
.expect("Failed to create GLFW window.");
Expand Down
2 changes: 1 addition & 1 deletion examples/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extern crate glfw;
use glfw::{Action, Context, CursorMode, Key};

fn main() {
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).ok().expect("Failed to init glfw");
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();

let (mut window, events) = glfw.create_window(800, 600, "Hello, I am a window.", glfw::WindowMode::Windowed)
.expect("Failed to create GLFW window.");
Expand Down
2 changes: 1 addition & 1 deletion examples/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extern crate glfw;
use glfw::Context;

fn main() {
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).ok().expect("Failed to init glfw");
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();

glfw.window_hint(glfw::WindowHint::Visible(true));

Expand Down
2 changes: 1 addition & 1 deletion examples/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn main() {
f: error_callback as fn(glfw::Error, String, &Cell<usize>),
data: Cell::new(0),
}
)).ok().expect("Failed to init glfw");
)).unwrap();

// Force the error callback to be triggered
glfw.window_hint(glfw::WindowHint::ContextVersion(40000, 3000)); // Ridiculous!
Expand Down
2 changes: 1 addition & 1 deletion examples/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extern crate glfw;
use glfw::{Action, Context, Key};

fn main() {
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).ok().expect("Failed to init glfw");
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();

glfw.window_hint(glfw::WindowHint::Resizable(true));

Expand Down
2 changes: 1 addition & 1 deletion examples/modes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
extern crate glfw;

fn main() {
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).ok().expect("Failed to init glfw");
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();

glfw.with_primary_monitor(|_, monitor| {
let _ = monitor.map(|monitor| {
Expand Down
2 changes: 1 addition & 1 deletion examples/monitors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extern crate glfw;
use glfw::{Action, Context, Key};

fn main() {
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).ok().expect("Failed to init glfw");
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();

glfw.with_connected_monitors(|_, monitors| {
for monitor in monitors.iter() {
Expand Down
2 changes: 1 addition & 1 deletion examples/render_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use glfw::{Action, Context, Key};
use std::thread::Builder;

fn main() {
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).ok().expect("Failed to init glfw");
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();

let (mut window, events) = glfw.create_window(300, 300, "Hello this is window", glfw::WindowMode::Windowed)
.expect("Failed to create GLFW window.");
Expand Down
2 changes: 1 addition & 1 deletion examples/title.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extern crate glfw;
use glfw::{Action, Context, Key};

fn main() {
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).ok().expect("Failed to init glfw");
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();

let (mut window, events) = glfw.create_window(400, 400, "English 日本語 русский язык 官話", glfw::WindowMode::Windowed)
.expect("Failed to create GLFW window.");
Expand Down
2 changes: 1 addition & 1 deletion examples/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extern crate glfw;
use glfw::{Action, Context, Key};

fn main() {
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).ok().expect("Failed to init glfw");
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();

let (mut window, events) = glfw.create_window(300, 300, "Hello this is window", glfw::WindowMode::Windowed)
.expect("Failed to create GLFW window.");
Expand Down
10 changes: 8 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
//! use glfw::{Action, Context, Key};
//!
//! fn main() {
//! let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).ok().expect("Failed to init glfw");
//! let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();
//!
//! // Create a windowed mode window and its OpenGL context
//! let (mut window, events) = glfw.create_window(300, 300, "Hello this is window", glfw::WindowMode::Windowed)
Expand Down Expand Up @@ -360,6 +360,12 @@ pub enum InitError {
Internal,
}

impl fmt::Display for InitError {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(f, "InitError: {:?}", *self)
}
}

/// Initializes the GLFW library. This must be called on the main platform
/// thread.
///
Expand All @@ -377,7 +383,7 @@ pub enum InitError {
/// extern crate glfw;
///
/// fn main() {
/// let glfw = glfw::init(glfw::FAIL_ON_ERRORS).ok().expect("Failed to init glfw");
/// let glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();
/// }
/// ~~~
///
Expand Down

0 comments on commit 5862e99

Please sign in to comment.