fn clone(&self) -> Self {
    match NonNull::new(unsafe { SDL_AllocPalette(self.len() as i32) }) {
      Some(nn) => {
        let out = Self {
          nn,
          _marker: PhantomData,
        };
        // Note(Lokathor): This is safe only as long as this slice never leaves
        // this function call.
        let self_slice = unsafe {
          core::slice::from_raw_parts(
            (*self.nn.as_ptr()).colors as *mut Color,
            (*self.nn.as_ptr()).ncolors as usize,
          )
        };
        out
          .set_colors(0, self_slice)
          .expect("Failed to copy the color data!");
        out
      }
      None => panic!("OOM: couldn't allocate an SDL_Palette!"),
    }
  }
/// Clones the colors into an entirely distinct `Palette` of the same length.
///
/// First a new palette of the same length is allocated, then all colors are
/// copied over.
///
/// ## Panics
///
/// * If the `SDL_Palette` cannot be allocated this will panic. That
///   essentially only happens if you're out of memory.
/// * If the colors cannot be copied over this will panic. It should be
///   impossible for that to fail, but hey.
Clones the colors into an entirely distinct `Palette` of the same length.
First a new palette of the same length is allocated, then all colors are
copied over.
Clones the colors into an entirely distinct ` Palette ` of the same length . First a new palette of the same length is allocated then all colors are copied over .
fn clone(&self) -> Self {
    match NonNull::new(unsafe { SDL_AllocPalette(self.len() as i32) }) {
      Some(nn) => {
        let out = Self {
          nn,
          _marker: PhantomData,
        };
        // Note(Lokathor): This is safe only as long as this slice never leaves
        // this function call.
        let self_slice = unsafe {
          core::slice::from_raw_parts(
            (*self.nn.as_ptr()).colors as *mut Color,
            (*self.nn.as_ptr()).ncolors as usize,
          )
        };
        out
          .set_colors(0, self_slice)
          .expect("Failed to copy the color data!");
        out
      }
      None => panic!("OOM: couldn't allocate an SDL_Palette!"),
    }
  }
fn clone ( & self ) -> Self { match NonNull :: new ( unsafe { SDL_AllocPalette ( self . len ( ) as i32 ) } ) { Some ( nn ) => { let out = Self { nn , _marker : PhantomData , } ; // Note(Lokathor): This is safe only as long as this slice never leaves // this function call. let self_slice = unsafe { core :: slice :: from_raw_parts ( ( * self . nn . as_ptr ( ) ) . colors as * mut Color , ( * self . nn . as_ptr ( ) ) . ncolors as usize , ) } ; out . set_colors ( 0 , self_slice ) . expect ( " " ) ; out } None => panic ! ( " " ) , } }
Clones the colors into an entirely distinct `Palette` of the same length.
Clones the colors into an entirely distinct ` Palette ` of the same length .
&self
&self
panics
If the `SDL_Palette` cannot be allocated this will panic. That
essentially only happens if you're out of memory.
If the colors cannot be copied over this will panic. It should be
impossible for that to fail, but hey.
If the ` SDL_Palette ` cannot be allocated this will panic . That essentially only happens if you ' re out of memory . If the colors cannot be copied over this will panic . It should be impossible for that to fail but hey .