not-fl3 / miniquad

Cross platform rendering in Rust
Apache License 2.0
1.54k stars 173 forks source link

Loosen `Fn` trait bounds on `fs::load_file` #433

Open sokorototo opened 4 months ago

sokorototo commented 4 months ago

https://github.com/not-fl3/miniquad/blob/8a150830d1db0618001d95f2e91d055680d8258c/src/fs.rs#L31-L44

fs::load_file is only expected to ever call its closure once, and thus only needs to implement FnOnce. Fn allows for the function to be called multiple times, and thus can't drop any wrapped values during its invocation. FnOnce is easier to implement and thus makes load_file easier to use.