Help with using stdweb:: js!

The JS code I care about is here:

The fragment I care about is:

var ext = gl.getExtension('EXT_blend_minmax');


gl.blendEquationSeparate(ext.MIN_EXT, ext.MAX_EXT);

what I have tried so far is:

        js! {
          var ext = gl.getExtension('EXT_blend_minmax');

The error I get is:

error: character literal may only contain one codepoint: 'EXT_blend_minmax'
40 |           var ext = gl.getExtension('EXT_blend_minmax');
   |                                     ^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

My question is: how do I fix this?

Use a string instead of an invalid character literal?

var ext = gl.getExtension("EXT_blend_minmax");

Remember that rust is not js however you slice it, so 'a' is char and "abc" is &'static str. 'abc' is not allowed because it’s supposed to be a char (single character) and not a string (str or any reference to it)

Wait … so in js! { … }
is the stuff in … tokenized as Rust code,
then we do a List<Rust_Token> => List<JS_Token> conversion?

Embeds JavaScript code into your Rust program.

Please note my use of italics on Embeds, it basically converts it into rust. In other words; js! is, from what I can gather, a JsTokenList => RustTokenList converter. Just use double quotes if possible, or write a macro to convert it.

Macros cannot contain anything that is lexically invalid as Rust code. Otherwise, how would the compiler parse them?


That makes sense.

A change in point of view is worth 80 IQ points. :slight_smile:

1 Like