You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use bevy::render::render_resource::ShaderSize;
use bevy::render::render_resource::ShaderType;
pub trait TraitToUseInGPU {
type DataContainer;
fn data(&self) -> Self::DataContainer;
}
// #[derive(ShaderType)] //This produces a compile error
struct SharedDataWithGPU<T>
where
T: TraitToUseInGPU,
<T as TraitToUseInGPU>::DataContainer: ShaderSize + ShaderType,
{
content: <T as TraitToUseInGPU>::DataContainer,
}
I'd like to set what data I can reach on the GPU through the above trait. I managed to do this(I think?) through an associated type.
The Struct SharedDataWithGPU is containing other omitted fields I removed for the sake of the example.
The compile error I am getting is "cannot define multiple where clauses on an Item";
If I were to implement ShaderType explicitly here the error may disappear but I still fail to understand why is the duplicate contraint imposed here?
Is it possible to use the derive macro in this case? And if not why not?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In the following minimal example:
I'd like to set what data I can reach on the GPU through the above trait. I managed to do this(I think?) through an associated type.
The Struct
SharedDataWithGPU
is containing other omitted fields I removed for the sake of the example.The compile error I am getting is "cannot define multiple where clauses on an Item";
If I were to implement ShaderType explicitly here the error may disappear but I still fail to understand why is the duplicate contraint imposed here?
Is it possible to use the derive macro in this case? And if not why not?
Beta Was this translation helpful? Give feedback.
All reactions