Skip to content

Commit 0ee5a1f

Browse files
committed
Clippy fixes
1 parent 6d02197 commit 0ee5a1f

2 files changed

Lines changed: 16 additions & 10 deletions

File tree

src/wrappers/win32/window/dc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl PixelFormat {
114114
}
115115
}
116116

117-
pub fn to_raw_descriptor(&self) -> PIXELFORMATDESCRIPTOR {
117+
pub fn to_raw_descriptor(self) -> PIXELFORMATDESCRIPTOR {
118118
PIXELFORMATDESCRIPTOR {
119119
nSize: size_of::<PIXELFORMATDESCRIPTOR>() as u16,
120120
nVersion: 1,

src/wrappers/win32/window/wgl.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,20 +100,26 @@ impl WglExtra {
100100
pub fn load() -> Result<Self, MissingExtensionFunctionError> {
101101
unsafe {
102102
Ok(Self {
103-
wglCreateContextAttribsARB: transmute(Self::load_fn(
104-
c"wglCreateContextAttribsARB",
103+
wglCreateContextAttribsARB: transmute::<*const c_void, WglCreateContextAttribsARB>(
104+
Self::load_fn(c"wglCreateContextAttribsARB")?,
105+
),
106+
wglChoosePixelFormatARB: transmute::<*const c_void, WglChoosePixelFormatARB>(
107+
Self::load_fn(c"wglChoosePixelFormatARB")?,
108+
),
109+
wglSwapIntervalEXT: transmute::<*const c_void, WglSwapIntervalEXT>(Self::load_fn(
110+
c"wglSwapIntervalEXT",
105111
)?),
106-
wglChoosePixelFormatARB: transmute(Self::load_fn(c"wglChoosePixelFormatARB")?),
107-
wglSwapIntervalEXT: transmute(Self::load_fn(c"wglSwapIntervalEXT")?),
108112
})
109113
}
110114
}
111115

112-
fn load_fn(
113-
name: &'static CStr,
114-
) -> Result<unsafe extern "system" fn() -> isize, MissingExtensionFunctionError> {
115-
unsafe { wglGetProcAddress(name.as_ptr() as *const u8) }
116-
.ok_or_else(|| MissingExtensionFunctionError { name })
116+
fn load_fn(name: &'static CStr) -> Result<*const c_void, MissingExtensionFunctionError> {
117+
let ptr = unsafe { wglGetProcAddress(name.as_ptr() as *const u8) };
118+
119+
match ptr {
120+
Some(ptr) => Ok(ptr as *const c_void),
121+
None => Err(MissingExtensionFunctionError { name }),
122+
}
117123
}
118124

119125
pub fn create_context_for_config(

0 commit comments

Comments
 (0)