-
I am using
js!
from stdweb. -
I have a snippet like:
let v : Value = (js!{ return (window.devicePixelRatio || 1) });
let dpc: i32 = v.into();
- I get a compile error of:
19 | let dpc: i32 = v.into();
| ^^^^ the trait `std::convert::From<stdweb::Value>` is not implemented for `i32`
|
= help: the following implementations were found:
<i32 as std::convert::From<bool>>
<i32 as std::convert::From<i16>>
<i32 as std::convert::From<i8>>
<i32 as std::convert::From<u16>>
<i32 as std::convert::From<u8>>
= note: required because of the requirements on the impl of `std::convert::Into<i32>` for `stdweb::Value`
- Now I am confused -- why does it not support i32? Well, let me try i16 anyway to see what happens, so I try:
let v : Value = (js!{ return (window.devicePixelRatio || 1) });
let dpc: i16 = v.into();
- This now gives me error:
19 | let dpc: i16 = v.into();
| ^^^^ the trait `std::convert::From<stdweb::Value>` is not implemented for `i16`
|
= help: the following implementations were found:
<i16 as std::convert::From<bool>>
<i16 as std::convert::From<i8>>
<i16 as std::convert::From<u8>>
= note: required because of the requirements on the impl of `std::convert::Into<i16>` for `stdweb::Value`
-
So this does not work either.
-
Questions:
7a. WTF is going on?
7b. How do I read out i32 from js! ?