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.
This PR uses Generic Associated Types to avoid the unsafety around
draw_handle
andsize_handle
, fixing a possible memory-safety violation in the process.Additionally, this uses the
stack_dst
crate to provideThemeDst
andWindowDst
traits (parameterised only byDraw
type), which allowsMultiTheme
to be made more generic and moved intokas
. As part of this, we also depend on theunsize
nightly feature (although this could be avoided if necessary).Unfortunately, the Rust's GAT implementation is too immature to enable by default, hence is gated behind the
gat
feature flag. As such, it doesn't play well with the usage ofstack_dst
, hence that is behind another flag and the two are mutually incompatible.This PR therefore complicates testing significantly, as well as any
Theme
implementation (including thecustom-theme
example), however I feel it is justified since:unsafe
(revealing a bug in the process), and are almost certainly the way forward (once the compiler properly supports this)stack_dst
allows for a much improvedMultiTheme
implementation with negligible performance impact and most of theunsafe
pushed into a small, shared crate (even if currently it has zero dependencies and few downloads), though it does seem sensible to feature-gate this dependencyUnfortunately the two features do not combine well, not only because of bugs around GATs, but also because
stack_dst::ValueA
is not parametrisable over lifetimes (probably a dedicatedRefA
type would be required).