Implement Clone for CompileOptions#148
Merged
antiagainst merged 2 commits intogoogle:mainfrom Mar 30, 2025
Merged
Conversation
Collaborator
|
Thanks for the pull request and terribly sorry for getting back sooo late--I missed the notification earlier so completely dropped the ball. :( I cannot recall why I didn't impl the |
Contributor
Author
|
@antiagainst Thanks, now it was my turn to disappear for a while! I rebased my fork on |
Collaborator
|
Thanks @simonask ! It looks good to me now. Can you address the Clippy failures and then we can merge? |
Collaborator
|
nvm--I fixed the small issue and landed it. thanks again! :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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::CompileOptionscould not implement the regularClonetrait, rather than its current specialfn clone() -> Option<Self>.This is a breaking change, because the signature of the
Clonetrait is different in the following ways:Selfrather thanOption<Self>. This seems more correct becauseshaderc_compile_options_clone()cannot fail except for heap allocation failure (it calls a nothrow trivial copy constructor), which is a degenerate scenario regardless.'arather than'_. This seems more correct, since the currentclone()does not borrow from the existing object.In addition, the inner
include_callback_fnwas changed fromBox<dyn Fn(...)>to beRc<dyn Fn(...)>. This should be fine becauseCompileOptionsis already!Senddue to its raw pointer member, and the function isFnrather thanFnMut.Despite this being technically a breaking change, I think it might still be worth it. I hope you will agree. :-)