Skip to content

Simplify WebGL example #1322

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

Closed
ibaryshnikov opened this issue Mar 6, 2019 · 3 comments
Closed

Simplify WebGL example #1322

ibaryshnikov opened this issue Mar 6, 2019 · 3 comments

Comments

@ibaryshnikov
Copy link
Member

Motivation

There is a function signature

pub fn link_program<'a, T: IntoIterator<Item = &'a WebGlShader>>(
    context: &WebGlRenderingContext,
    shaders: T,
) -> Result<WebGlProgram, String> {

It's hard to teach, because it requires additional explanations about iterators and lifetimes.
There is also String::from("") and "".into(), which produces the question "why are they different?".

Proposed Solution

Use distinct arguments instead of the iterator

pub fn link_program(
    context: &WebGlRenderingContext,
    vert_shader: &WebGlShader,
    frag_shader: &WebGlShader,
) -> Result<WebGlProgram, String> {

Alternatives

Keep it as is

Additional Context

I'd like to submit an update for this example if it's a good idea

@alexcrichton
Copy link
Contributor

Sounds great to me! If you'd like to send a PR I'm sure we can find someone happy to review :)

@ibaryshnikov
Copy link
Member Author

Should I also update it to a new behavior (like in without-a-bundler example)? At the moment npm run serve builds the page, but the code fails to run when I navigate to the browser.

@alexcrichton
Copy link
Contributor

Hm these are unfortunately likely broken on master due to #1318, which I hope to fix today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants