From 33babac3be6d1b2d1b084d77135df635a9221c2c Mon Sep 17 00:00:00 2001 From: Chris Parker Date: Sun, 27 Dec 2015 17:11:50 -0500 Subject: [PATCH] replaced num::FromPrimitive in /sdl2-sys/src/video.rs with own trait FromPrimitive, then removed num dependency from sdl2-sys. --- sdl2-sys/Cargo.toml | 1 - sdl2-sys/src/lib.rs | 1 - sdl2-sys/src/video.rs | 8 ++++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sdl2-sys/Cargo.toml b/sdl2-sys/Cargo.toml index 7e23edac..4daa1528 100644 --- a/sdl2-sys/Cargo.toml +++ b/sdl2-sys/Cargo.toml @@ -14,7 +14,6 @@ name = "sdl2_sys" path = "src/lib.rs" [dependencies] -num = "0.1" libc = "0.2" [build-dependencies.pkg-config] diff --git a/sdl2-sys/src/lib.rs b/sdl2-sys/src/lib.rs index 5b24c969..a988c095 100644 --- a/sdl2-sys/src/lib.rs +++ b/sdl2-sys/src/lib.rs @@ -2,7 +2,6 @@ #![cfg_attr(feature = "no_std", no_std)] #![allow(non_camel_case_types)] -extern crate num; extern crate libc; #[cfg(feature = "no_std")] extern crate core; diff --git a/sdl2-sys/src/video.rs b/sdl2-sys/src/video.rs index b89ec9e1..2da23f7f 100644 --- a/sdl2-sys/src/video.rs +++ b/sdl2-sys/src/video.rs @@ -4,7 +4,6 @@ use surface::SDL_Surface; #[cfg(feature = "no_std")] use core::prelude::*; use libc::{c_void, c_int, c_float, c_char, uint16_t, uint32_t}; -use num::FromPrimitive; pub type SDL_bool = c_int; @@ -95,6 +94,11 @@ pub enum SDL_GLattr { SDL_GL_FRAMEBUFFER_SRGB_CAPABLE = 23 } +trait FromPrimitive { + fn from_i64(n: i64) -> Option; + fn from_u64(n: u64) -> Option; +} + impl FromPrimitive for SDL_GLattr { fn from_i64(n: i64) -> Option { use self::SDL_GLattr::*; @@ -128,7 +132,7 @@ impl FromPrimitive for SDL_GLattr { }) } - fn from_u64(n: u64) -> Option { FromPrimitive::from_i64(n as i64) } + fn from_u64(n: u64) -> Option { SDL_GLattr::from_i64(n as i64) } } #[derive(Copy, Clone)]