brendanzab / gl-rs

An OpenGL function pointer loader for Rust
Apache License 2.0
678 stars 117 forks source link

[metaloadfn] trait objects without an explicit `dyn` are deprecated #522

Open TheAifam5 opened 4 years ago

TheAifam5 commented 4 years ago
  |
9 |         fn metaloadfn(mut loadfn: &mut FnMut(&str) -> *const __gl_imports::raw::c_void,
  |                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `dyn`: `dyn FnMut(&str) -> *const __gl_imports::raw::c_void`

compiled with forbid(rust_2018_idioms)

PutterBeanut commented 3 years ago

First off, this isn't a GL problem, it's a Rust problem. But for an explanation: when using a trait, they actually don't have a known size at compile time, so you use the dyn keyword allows Rust to say "okay okay, I'll trust you on this one," in which FnMut most likely is or implements a trait.

Lokathor commented 3 years ago

FnMut is a trait. It doesn't implement a trait.

Also, the real answer to this is that "forbid the 2018 idioms" is not a useful thing to do. This crate will likely never move past 2015 edition.