Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Also implement AsUniformValue for textures directly #1956

Merged
merged 2 commits into from Aug 12, 2021

Commits on Aug 10, 2021

  1. Add test showcasing lifetime issue of AsUniformValue for Texture2d

    Currently this fails to compile with:
    ```
    error[E0515]: cannot return value referencing function parameter `texture`
       --> tests/texture_creation.rs:103:9
        |
    103 |         texture.as_uniform_value()
        |         -------^^^^^^^^^^^^^^^^^^^
        |         |
        |         returns a value referencing data owned by the current function
        |         `texture` is borrowed here
    
    error: aborting due to previous error
    
    For more information about this error, try `rustc --explain E0515`.
    ```
    strohel committed Aug 10, 2021
    Copy the full SHA
    9212005 View commit details
    Browse the repository at this point in the history
  2. 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.
    strohel committed Aug 10, 2021
    Copy the full SHA
    3e3365e View commit details
    Browse the repository at this point in the history