Skip to content

Should all SDL types have raw() accessors? #309

Open
@nukep

Description

@nukep

Back when "refactoring", I inadvertently broke the rust-sdl2_image library by removing the raw accessor from Renderer: 6070bfb#commitcomment-9502773

Turns out the raw accessors are useful for more than just internal use.

For anyone extending rust-sdl2 to provide functionality that's out of scope here (such as sdl2-mixer, sdl2-ttf, etc.), it could be useful to obtain the raw pointers.

If we decide to do this, I propose adding a raw_mut() accessor as well. This will be especially important for when #108 is addressed):

#[inline] pub unsafe fn raw(&self) -> *const ll::SDL_Renderer { self.raw }

#[inline] pub unsafe fn raw_mut(&self) -> *mut ll::SDL_Renderer {
    use std::mem;
    unsafe { mem::transmute(self.raw) }
}

raw_mut() would accept the immutable &self to not break things like Renderer.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions