mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-25 23:01:30 +11:00
Merge pull request #224 from andrewrk/fix-error-trait
fix for latest rustc
This commit is contained in:
commit
aa92625064
|
@ -1,4 +1,4 @@
|
||||||
#[derive(Clone, Show, Copy)]
|
#[derive(Clone, Debug, Copy)]
|
||||||
pub enum Event {
|
pub enum Event {
|
||||||
/// The size of the window has changed.
|
/// The size of the window has changed.
|
||||||
Resized(u32, u32),
|
Resized(u32, u32),
|
||||||
|
@ -38,13 +38,13 @@ pub enum Event {
|
||||||
|
|
||||||
pub type ScanCode = u8;
|
pub type ScanCode = u8;
|
||||||
|
|
||||||
#[derive(Show, Hash, PartialEq, Eq, Clone, Copy)]
|
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy)]
|
||||||
pub enum ElementState {
|
pub enum ElementState {
|
||||||
Pressed,
|
Pressed,
|
||||||
Released,
|
Released,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Show, Hash, PartialEq, Eq, Clone, Copy)]
|
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy)]
|
||||||
pub enum MouseButton {
|
pub enum MouseButton {
|
||||||
LeftMouseButton,
|
LeftMouseButton,
|
||||||
RightMouseButton,
|
RightMouseButton,
|
||||||
|
@ -52,7 +52,7 @@ pub enum MouseButton {
|
||||||
OtherMouseButton(u8),
|
OtherMouseButton(u8),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Show, Hash, PartialEq, Eq, Clone, Copy)]
|
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy)]
|
||||||
pub enum VirtualKeyCode {
|
pub enum VirtualKeyCode {
|
||||||
/// The '1' key over the letters.
|
/// The '1' key over the letters.
|
||||||
Key1,
|
Key1,
|
||||||
|
|
22
src/lib.rs
22
src/lib.rs
|
@ -67,14 +67,14 @@ mod events;
|
||||||
pub struct MonitorID(winimpl::MonitorID);
|
pub struct MonitorID(winimpl::MonitorID);
|
||||||
|
|
||||||
/// Error that can happen while creating a window or a headless renderer.
|
/// Error that can happen while creating a window or a headless renderer.
|
||||||
#[derive(Clone, Show, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
pub enum CreationError {
|
pub enum CreationError {
|
||||||
OsError(String),
|
OsError(String),
|
||||||
NotSupported,
|
NotSupported,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::error::Error for CreationError {
|
impl CreationError {
|
||||||
fn description(&self) -> &str {
|
fn to_string(&self) -> &str {
|
||||||
match self {
|
match self {
|
||||||
&CreationError::OsError(ref text) => text.as_slice(),
|
&CreationError::OsError(ref text) => text.as_slice(),
|
||||||
&CreationError::NotSupported => "Some of the requested attributes are not supported",
|
&CreationError::NotSupported => "Some of the requested attributes are not supported",
|
||||||
|
@ -82,8 +82,20 @@ impl std::error::Error for CreationError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Display for CreationError {
|
||||||
|
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
|
||||||
|
formatter.write_str(self.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::error::Error for CreationError {
|
||||||
|
fn description(&self) -> &str {
|
||||||
|
self.to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// All APIs related to OpenGL that you can possibly get while using glutin.
|
/// All APIs related to OpenGL that you can possibly get while using glutin.
|
||||||
#[derive(Show, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum Api {
|
pub enum Api {
|
||||||
/// The classical OpenGL. Available on Windows, Linux, OS/X.
|
/// The classical OpenGL. Available on Windows, Linux, OS/X.
|
||||||
OpenGl,
|
OpenGl,
|
||||||
|
@ -91,7 +103,7 @@ pub enum Api {
|
||||||
OpenGlEs,
|
OpenGlEs,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Show, Copy)]
|
#[derive(Debug, Copy)]
|
||||||
pub enum MouseCursor {
|
pub enum MouseCursor {
|
||||||
/// The platform-dependent default cursor.
|
/// The platform-dependent default cursor.
|
||||||
Default,
|
Default,
|
||||||
|
|
|
@ -519,8 +519,7 @@ impl Window {
|
||||||
mem::transmute(buffer.as_mut_ptr()),
|
mem::transmute(buffer.as_mut_ptr()),
|
||||||
buffer.len() as libc::c_int, ptr::null_mut(), ptr::null_mut());
|
buffer.len() as libc::c_int, ptr::null_mut(), ptr::null_mut());
|
||||||
|
|
||||||
str::from_utf8(buffer.as_slice().slice_to(count as usize))
|
str::from_utf8(&buffer.as_slice()[..count as usize]).unwrap_or("").to_string()
|
||||||
.unwrap_or("").to_string()
|
|
||||||
};
|
};
|
||||||
|
|
||||||
for chr in written.as_slice().chars() {
|
for chr in written.as_slice().chars() {
|
||||||
|
|
Loading…
Reference in a new issue