Commit 1ebe097
authored
Implement Clone for CompileOptions (#148)
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:
- It returns `Self` rather than `Option<Self>`. This
seems more correct because `shaderc_compile_options_clone()`
cannot fail except for heap allocation failure (it calls a
nothrow trivial copy constructor), which is a degenerate
scenario regardless.
- The lifetime parameter on the return value is `'a`
rather than `'_`. This seems more correct, since the
current `clone()` does not borrow from the existing object.
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`.1 parent 65388cd commit 1ebe097
1 file changed
Lines changed: 25 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
| |||
697 | 698 | | |
698 | 699 | | |
699 | 700 | | |
700 | | - | |
| 701 | + | |
701 | 702 | | |
702 | 703 | | |
703 | 704 | | |
| |||
753 | 754 | | |
754 | 755 | | |
755 | 756 | | |
756 | | - | |
757 | | - | |
758 | | - | |
759 | | - | |
760 | | - | |
761 | | - | |
762 | | - | |
763 | | - | |
764 | | - | |
765 | | - | |
766 | | - | |
767 | | - | |
768 | | - | |
769 | | - | |
770 | | - | |
771 | | - | |
772 | | - | |
773 | | - | |
774 | | - | |
775 | 757 | | |
776 | 758 | | |
777 | 759 | | |
| |||
842 | 824 | | |
843 | 825 | | |
844 | 826 | | |
845 | | - | |
| 827 | + | |
846 | 828 | | |
847 | 829 | | |
848 | 830 | | |
| |||
1170 | 1152 | | |
1171 | 1153 | | |
1172 | 1154 | | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
1173 | 1176 | | |
1174 | 1177 | | |
1175 | 1178 | | |
| |||
1496 | 1499 | | |
1497 | 1500 | | |
1498 | 1501 | | |
1499 | | - | |
| 1502 | + | |
1500 | 1503 | | |
1501 | 1504 | | |
1502 | 1505 | | |
| |||
0 commit comments