Skip to content

Commit

Permalink
Also implement AsUniformValue for Texture2d and friends directly
Browse files Browse the repository at this point in the history
In addition to implementing if for references, i.e.
`impl<'a> AsUniformValue for &'a {myname}`.

The method `as_uniform_value(&self)` takes self by reference, so there
should be no need to require the second-level reference.

This allows a longer lifetime to be automatically inferred. Fixes
compilation of the texture_2d_as_uniform_value_lifetime() test from the
previous commit.

This commit doesn't remove the original impl above in order not to introduce
breaking changes. Removing would mean every texture passing in `uniform! {}`
would have to change.
  • Loading branch information
strohel committed Aug 10, 2021
1 parent 9212005 commit 3e3365e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions build/textures.rs
Expand Up @@ -425,6 +425,13 @@ fn build_texture<W: Write>(dest: &mut W, ty: TextureType, dimensions: TextureDim
}}
}}
impl AsUniformValue for {myname} {{
#[inline]
fn as_uniform_value(&self) -> UniformValue {{
UniformValue::{myname}(self, None)
}}
}}
impl<'a> AsUniformValue for Sampler<'a, {myname}> {{
#[inline]
fn as_uniform_value(&self) -> UniformValue {{
Expand Down

0 comments on commit 3e3365e

Please sign in to comment.