diff --git a/changelog.md b/changelog.md index 09c4ab06e4..7dcbfaaace 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,8 @@ when upgrading from a version of rust-sdl2 to another. ### Next +[PR #1473](https://github.com/Rust-SDL2/rust-sdl2/pull/1473) **BREAKING CHANGE** Fix UB in `ToColor` implementations and remove implementation for `isize`. + [PR #1414](https://github.com/Rust-SDL2/rust-sdl2/pull/1414) Use `TTF_GlyphIsProvided32` and `TTF_GlyphMetrics32` instead of the 16 bit ones. [PR #1435](https://github.com/Rust-SDL2/rust-sdl2/pull/1435) **BREAKING CHANGE** Fix some undefined behavior. Breaking changes: `mixer::Chunk`'s fields are now private and callbacks to `TimerSubsystem::add_timer` must now live for `'static`, also allowing some lifetime parameters to be removed. diff --git a/src/sdl2/gfx/primitives.rs b/src/sdl2/gfx/primitives.rs index 7cce5413fe..2fb6fd6d62 100644 --- a/src/sdl2/gfx/primitives.rs +++ b/src/sdl2/gfx/primitives.rs @@ -5,7 +5,6 @@ use libc::c_void; use libc::{c_char, c_int}; use pixels; use render::Canvas; -use std::convert::TryFrom; use std::ffi::CString; use std::ptr; use surface::Surface; @@ -36,6 +35,7 @@ impl ToColor for (u8, u8, u8, u8) { } } +// for 0xXXXXXXXX impl ToColor for u32 { #[inline] fn as_rgba(&self) -> (u8, u8, u8, u8) { @@ -49,22 +49,6 @@ impl ToColor for u32 { } } -// for 0xXXXXXXXX -impl ToColor for isize { - #[inline] - fn as_rgba(&self) -> (u8, u8, u8, u8) { - let [r, g, b, a] = u32::try_from(*self) - .expect("Can't convert to Color Type") - .to_be_bytes(); - (r, g, b, a) - } - - #[inline] - fn as_u32(&self) -> u32 { - u32::try_from(*self).expect("Can't convert to Color Type") - } -} - /// For drawing with rust-sdl2 Renderer pub trait DrawRenderer { fn pixel(&self, x: i16, y: i16, color: C) -> Result<(), String>;