pub fn with_colors(colors: &[Color]) -> Result<Self, String> {
        let pal = r#try!(Self::new(colors.len()));

        // Already validated, so don't check again
        let ncolors = colors.len() as ::libc::c_int;

        let result = unsafe {
            let mut raw_colors: Vec<sys::SDL_Color> = colors.iter()
                .map(|color| color.raw())
                .collect();

            let pal_ptr = (&mut raw_colors[0]) as *mut sys::SDL_Color;

            sys::SDL_SetPaletteColors(pal.raw, pal_ptr, 0, ncolors)
        };

        if result < 0 {
            Err(get_error())
        } else {
            Ok(pal)
        }
    }
/// Creates a palette from the provided colors
Creates a palette from the provided colors
Creates a palette from the provided colors
pub fn with_colors(colors: &[Color]) -> Result<Self, String> {
        let pal = r#try!(Self::new(colors.len()));
        // Already validated, so don't check again
        let ncolors = colors.len() as ::libc::c_int;
        let result = unsafe {
            let mut raw_colors: Vec<sys::SDL_Color> = colors.iter()
                .map(|color| color.raw())
                .collect();
            let pal_ptr = (&mut raw_colors[0]) as *mut sys::SDL_Color;
            sys::SDL_SetPaletteColors(pal.raw, pal_ptr, 0, ncolors)
        };
        if result < 0 {
            Err(get_error())
        } else {
            Ok(pal)
        }
    }
pub fn with_colors ( colors : & [ Color ] ) -> Result < Self , String > { let pal = r#try ! ( Self new ( colors len ( ) ) ) ; // Already validated, so don't check again let ncolors = colors . len ( ) as :: libc :: c_int ; let result = unsafe { let mut raw_colors : Vec < sys :: SDL_Color > = colors . iter ( ) . map ( | color | color . raw ( ) ) . collect ( ) ; let pal_ptr = ( & mut raw_colors [ 0 ] ) as * mut sys :: SDL_Color ; sys :: SDL_SetPaletteColors ( pal . raw , pal_ptr , 0 , ncolors ) } ; if result < 0 { Err ( get_error ( ) ) } else { Ok ( pal ) } }
Creates a palette from the provided colors
Creates a palette from the provided colors
colors
&[Color]
colors
&[Color]