Skip to content

Commit

Permalink
Improve the UX of the Window interface.
Browse files Browse the repository at this point in the history
Makes it clonable and removes the "unsafe" from the `Window::from_ref`
method.

Addresses Rust-SDL2#1367
  • Loading branch information
iddm committed Jan 26, 2024
1 parent b654517 commit 92732e4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/sdl2/video.rs
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,7 @@ impl FlashOperation {
/// Note: If a `Window` goes out of scope but it cloned its context,
/// then the `SDL_Window` will not be destroyed until there are no more references to the `WindowContext`.
/// This may happen when a `TextureCreator<Window>` outlives the `Canvas<Window>`
#[derive(Clone)]
pub struct Window {
context: Rc<WindowContext>,
}
Expand Down Expand Up @@ -1324,7 +1325,7 @@ impl Window {

#[inline]
/// Create a new `Window` without taking ownership of the `WindowContext`
pub const unsafe fn from_ref(context: Rc<WindowContext>) -> Window {
pub const fn from_ref(context: Rc<WindowContext>) -> Window {
Window { context }
}

Expand Down

0 comments on commit 92732e4

Please sign in to comment.