P.291 のコードがビルドできない
sago35 opened this issue · comments
embedded_graphics_web_simulator::*
のままではビルドできませんでした。
以下に変更することで npm start
できました。
@@ -1,26 +1,28 @@
-use embedded_graphics_web_simulator::*;
+use embedded_graphics_web_simulator::{
+ display::WebSimulatorDisplay, output_settings::OutputSettingsBuilder,
+};
use wasm_bindgen::prelude::*;
use web_sys::console;
use embedded_graphics::{
image::*,
pixelcolor::Rgb565,
prelude::*,
};
use wio_splash::WioSplash;
// This is like the `main` function, except for JavaScript.
#[wasm_bindgen(start)]
pub fn main_js() -> Result<(), JsValue> {
#[cfg(debug_assertions)]
console_error_panic_hook::set_once();
let output_settings = OutputSettingsBuilder::new().build();
let mut display = WebSimulatorDisplay::new((320, 240), &output_settings);
let raw = ImageRawLE::new(include_bytes!("./assets/ferris.raw"), 86, 64);
let splash = WioSplash::new(Rgb565::GREEN, raw);
splash.draw(&mut display).unwrap();
Ok(())
}
修正前のコード (書籍のまま) だと以下のエラーになりました。
$ cargo build
warning: Found `debug_assertions` in `target.'cfg(...)'.dependencies`. This value is not supported for selecting dependencies and will not work as expected. To learn more visit https://doc.rust-lang.org/carg
o/reference/specifying-dependencies.html#platform-specific-dependencies
Compiling basic_example v0.1.0 (/home/sago35/dev/src/github.com/rahul-thakoor/embedded-graphics-web-simulator/examples/basic)
error[E0433]: failed to resolve: use of undeclared type `OutputSettingsBuilder`
--> src/lib.rs:18:27
|
18 | let output_settings = OutputSettingsBuilder::new().build();
| ^^^^^^^^^^^^^^^^^^^^^ not found in this scope
|
help: consider importing one of these items
|
1 | use crate::output_settings::OutputSettingsBuilder;
|
1 | use embedded_graphics_web_simulator::output_settings::OutputSettingsBuilder;
|
error[E0433]: failed to resolve: use of undeclared type `WebSimulatorDisplay`
--> src/lib.rs:19:23
|
19 | let mut display = WebSimulatorDisplay::new((320, 240), &output_settings);
| ^^^^^^^^^^^^^^^^^^^ not found in this scope
|
help: consider importing one of these items
|
1 | use crate::display::WebSimulatorDisplay;
|
1 | use embedded_graphics_web_simulator::display::WebSimulatorDisplay;
|
warning: unused import: `embedded_graphics_web_simulator::*`
--> src/lib.rs:1:5
|
1 | use embedded_graphics_web_simulator::*;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: unused import: `web_sys::console`
--> src/lib.rs:3:5
|
3 | use web_sys::console;
| ^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors; 2 warnings emitted
For more information about this error, try `rustc --explain E0433`.
error: could not compile `basic_example`
To learn more, run the command again with --verbose.
version 等は以下の通りです。
$ git remote -v
origin https://github.com/rahul-thakoor/embedded-graphics-web-simulator (fetch)
origin git@github.com:rahul-thakoor/embedded-graphics-web-simulator (push)
$ git rev-parse HEAD
8ba90f5404b59d3846b689d87f81254352adebee
ご不便おかけしました。ありがとうございます。