1 From 4d9e740dfd80df976d976e21a7e33fd9f8b3c362 Mon Sep 17 00:00:00 2001
2 From: Kostya Shishkov <kostya.shishkov@gmail.com>
3 Date: Fri, 22 Nov 2019 17:47:54 +0100
4 Subject: [PATCH 1/4] remove not really needed dependencies
8 src/sdl/event.rs | 20 +++++++-------------
10 src/sdl/video.rs | 8 --------
11 4 files changed, 7 insertions(+), 25 deletions(-)
13 diff --git a/Cargo.toml b/Cargo.toml
14 index b53c715..ddf8523 100644
17 @@ -16,6 +16,4 @@ name = "sdl"
18 path = "src/sdl/lib.rs"
24 diff --git a/src/sdl/event.rs b/src/sdl/event.rs
25 index 17e2cff..12812f8 100644
26 --- a/src/sdl/event.rs
27 +++ b/src/sdl/event.rs
32 -use num::FromPrimitive;
36 @@ -512,7 +511,7 @@ pub enum Key {
40 -impl FromPrimitive for Key {
42 fn from_i64(n: i64) -> Option<Key> {
45 @@ -753,11 +752,11 @@ impl FromPrimitive for Key {
49 - fn from_u64(n: u64) -> Option<Key> { FromPrimitive::from_i64(n as i64) }
50 + fn from_u64(n: u64) -> Option<Key> { Self::from_i64(n as i64) }
53 fn wrap_key(i: ll::SDLKey) -> Option<Key> {
54 - FromPrimitive::from_usize(i as usize)
55 + Key::from_u64(i as u64)
58 #[derive(PartialEq, Eq, Copy, Clone)]
59 @@ -829,7 +828,7 @@ pub enum Mouse {
63 -impl FromPrimitive for Mouse {
65 fn from_i64(n: i64) -> Option<Mouse> {
68 @@ -840,12 +839,10 @@ impl FromPrimitive for Mouse {
73 - fn from_u64(n: u64) -> Option<Mouse> { FromPrimitive::from_i64(n as i64) }
76 fn wrap_mouse(bitflags: u8) -> Option<Mouse> {
77 - FromPrimitive::from_u8(bitflags)
78 + Mouse::from_i64(bitflags as i64)
81 #[derive(PartialEq, Eq, Copy, Clone)]
82 @@ -903,7 +900,7 @@ fn wrap_event(raw: ll::SDL_Event) -> Event {
83 let ty = if ty.is_null() { return Event::None; }
86 - let ty : EventType = match FromPrimitive::from_usize(ty as usize) {
87 + let ty : EventType = match EventType::from_u64(ty as u64) {
89 None => return Event::None
91 @@ -1022,9 +1019,6 @@ pub enum EventType {
93 pub fn get_state(&self) -> bool { get_event_state(*self) }
94 pub fn set_state(&self, state: bool) { set_event_state(*self, state) }
97 -impl FromPrimitive for EventType {
98 fn from_i64(n: i64) -> Option<EventType> {
99 Some(match n as ll::SDL_EventType {
100 ll::SDL_NOEVENT => EventType::None,
101 @@ -1048,7 +1042,7 @@ impl FromPrimitive for EventType {
105 - fn from_u64(n: u64) -> Option<EventType> { FromPrimitive::from_i64(n as i64) }
106 + fn from_u64(n: u64) -> Option<EventType> { Self::from_i64(n as i64) }
109 pub fn pump_events() {
110 diff --git a/src/sdl/lib.rs b/src/sdl/lib.rs
111 index cf04157..0f2a910 100644
115 #![allow(raw_pointer_derive)]
123 diff --git a/src/sdl/video.rs b/src/sdl/video.rs
124 index 3f7020a..64084f8 100644
125 --- a/src/sdl/video.rs
126 +++ b/src/sdl/video.rs
129 use libc::{c_int, c_float};
133 use std::ffi::CString;
135 @@ -305,13 +304,6 @@ pub enum Color {
139 -impl ::rand::Rand for Color {
140 - fn rand<R: ::rand::Rng>(rng: &mut R) -> Color {
141 - if rng.gen() { RGBA(rng.gen(), rng.gen(), rng.gen(), rng.gen()) }
142 - else { RGB(rng.gen(), rng.gen(), rng.gen()) }
147 pub fn from_mapped(bit: u32, fmt: *const ll::SDL_PixelFormat) -> Color {