随笔分类 -  Rust

摘要:fn multiply(num: Option<usize>) -> usize { return num.unwrap_or(0) * 5; } fn multiply1(num: Option<usize>) -> Option<usize> { match num { Some(num) => 阅读全文
posted @ 2023-05-18 20:32 Zhentiw 阅读(22) 评论(0) 推荐(0) 编辑
摘要:enum Color { Red, Green, Blue, Yellow, } impl Color { fn is_green(&self) -> bool { if let Color::Green = self { return true; } return false; } fn is_g 阅读全文
posted @ 2023-05-17 14:53 Zhentiw 阅读(22) 评论(0) 推荐(0) 编辑
摘要:Typescript import * as fs from "fs"; fs.readFileSync("project/lines", { encoding: "utf-8" }) .toString() .split("\n") .filter((_, i) => i % 2 0) .filt 阅读全文
posted @ 2023-05-16 14:34 Zhentiw 阅读(15) 评论(0) 推荐(0) 编辑
摘要:String collect: automaticlly calling concat on string let foo: String = vec!["this", "is", "a", "test"] .into_iter() .collect(); println!("{:?}", foo) 阅读全文
posted @ 2023-05-15 15:01 Zhentiw 阅读(70) 评论(0) 推荐(0) 编辑
摘要:Few intertesting things from Rust Option<T>: with Some, unwrap() function todo(): to skil compiler error for a while unreachable(): similar to Typescr 阅读全文
posted @ 2023-05-09 01:03 Zhentiw 阅读(15) 评论(0) 推荐(0) 编辑
摘要:wasm-pack is a tool that seeks to be a one-stop shop for building and working with Rust generated WebAssembly that you would like to interop with Java 阅读全文
posted @ 2018-11-08 05:40 Zhentiw 阅读(286) 评论(0) 推荐(0) 编辑
摘要:js-sys offers bindings to all the global APIs available in every JavaScript environment as defined by the ECMAScript standard. In this lesson, we will 阅读全文
posted @ 2018-11-07 04:10 Zhentiw 阅读(338) 评论(0) 推荐(0) 编辑
摘要:While JavaScript has a garbage-collected heap, WebAssembly has a linear memory space. Nevertheless using a JavaScript ArrayBuffer, we can read and wri 阅读全文
posted @ 2018-11-07 03:59 Zhentiw 阅读(401) 评论(0) 推荐(0) 编辑
摘要:Having some kind of debugging tool in our belt is extremely useful before writing a lot of code. In this lesson we build a println!()-style syntax usi 阅读全文
posted @ 2018-11-02 04:13 Zhentiw 阅读(430) 评论(0) 推荐(0) 编辑
摘要:Previous to this post, we set up our own Rust/wasm project from scratch. The Rust/wasm team ships a template for you to get started right away. In thi 阅读全文
posted @ 2018-10-23 17:44 Zhentiw 阅读(332) 评论(0) 推荐(0) 编辑
摘要:Interoperability between JavaScript and Rust is limited to numerics and accessing memory directly. Since this can be exhausting and overwhelming to do 阅读全文
posted @ 2018-10-23 03:34 Zhentiw 阅读(468) 评论(0) 推荐(0) 编辑
摘要:In some cases it’s useful to be able to invoke a JavaScript function inside Rust. This session showcases how this can be done, by passing along our Ja 阅读全文
posted @ 2018-10-21 03:41 Zhentiw 阅读(421) 评论(0) 推荐(0) 编辑
摘要:In this lesson we are going to setup a project from scratch by introducing the JavaScript snippet to load a WebAssembly module. We demonstrate two dif 阅读全文
posted @ 2018-10-19 02:36 Zhentiw 阅读(272) 评论(0) 推荐(0) 编辑
摘要:In order to setup a project we need to install the nightly build of Rust and add the WebAssembly target. For an improved workflow we also install the 阅读全文
posted @ 2018-10-19 02:07 Zhentiw 阅读(300) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示