google / shaderc-rs

Rust bindings for the shaderc library.
https://docs.rs/shaderc
Apache License 2.0
261 stars 64 forks source link

Implement Clone for CompileOptions #148

Open simonask opened 6 months ago

simonask commented 6 months ago

Motivation: shaderc::CompileOptions::clone() is actually kind of awkward and not particularly useful, because its return value has the inferred lifetime parameter '_ from the original object, rather than 'a, so the original object must be kept around anyway.

As far as I can tell, there is no reason that shaderc::CompileOptions could not implement the regular Clone trait, rather than its current special fn clone() -> Option<Self>.

This is a breaking change, because the signature of the Clone trait is different in the following ways:

In addition, the inner include_callback_fn was changed from Box<dyn Fn(...)> to be Rc<dyn Fn(...)>. This should be fine because CompileOptions is already !Send due to its raw pointer member, and the function is Fn rather than FnMut.

Despite this being technically a breaking change, I think it might still be worth it. I hope you will agree. :-)