1.0.0 • Published 7 months ago

wasm-game-of-life-euds63 v1.0.0

Weekly downloads
-
License
-
Repository
-
Last release
7 months ago

wasm-game-of-life

About

a project to learn Rust

Usage

Clone this Template

git clone

Build with wasm-pack build

wasm-pack build

收获

  1. 自定义macro

    • 步骤

      1. 在一个模块中定义并导出自定义宏
        // utils.rs
        #[macro_export]
        macro_rules! log {
           ( $( $t:tt )* ) => {
              web_sys::console::log_1(&format!( $( $t )* ).into());
           }
        }
      2. 在其他模块中使用

        // lib.rs
        #[macro_use]
        mod utils;
        
        mod universe;
        
        // universe.rs
        use crate::utils;
        // 直接使用
        log!("This is a log message: {}", some_variable);
  2. Always let profiling guide your focus

踩坑

  1. npm install 失败
  1. wasm-build 失败
  1. wasm-pack test --chrome --headless 失败

待办

参考

1.0.0

7 months ago

0.1.0

7 months ago