From 3e3365ef309f8909fc2d769c47089ba167971f23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Laitl?= Date: Mon, 9 Aug 2021 22:12:56 +0200 Subject: [PATCH] Also implement AsUniformValue for Texture2d and friends directly 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. --- build/textures.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/build/textures.rs b/build/textures.rs index bd684dfa8a..bd824c5007 100644 --- a/build/textures.rs +++ b/build/textures.rs @@ -425,6 +425,13 @@ fn build_texture(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 {{