Jekyll2025-08-25T09:21:30+00:00https://rustwasm.github.io/feed.xmlRust and WebAssemblyStay up to date with events, learning resources, and recent developments in Rust and WebAssembly community.This Week in Rust and WebAssembly 152019-03-28T00:00:00+00:002019-03-28T00:00:00+00:00https://rustwasm.github.io/2019/03/28/this-week-in-rust-and-wasm-015<p>Hello and welcome to another issue of <em>This Week in Rust and WebAssembly</em>!</p> <p><a href="https://rust-lang.org">Rust</a> is a systems language pursuing the trifecta: safety, concurrency, and speed.</p> <p><a href="http://webassembly.org">WebAssembly</a> is a stack-based virtual machine and instruction set. It is fast, safe, portable, and part of the open Web platform. By compiling to WebAssembly, we can run Rust code on the Web!</p> <p>This is a weekly summary of Rust and WebAssembly’s progress and community.</p> <p>Did we miss something? Tweet to us at <a href="https://twitter.com/rustwasm">@rustwasm</a> or <a href="https://github.com/rustwasm/rustwasm.github.io">send us a pull request</a>.</p> <p><strong>Want to get involved in Rust and WebAssembly? <a href="https://github.com/rustwasm/team/blob/master/README.md#get-involved">Join the Rust and WebAssembly working group!</a></strong></p> <h2 id="news-and-blog-posts-from-around-the-web">News and Blog Posts from Around the Web</h2> <p><em>Want to make sure something ends up on this list next time we publish an issue? <a href="https://github.com/rustwasm/team/issues/79">Leave a comment on this issue.</a></em></p> <ul> <li><a href="https://hacks.mozilla.org/2019/03/standardizing-wasi-a-webassembly-system-interface/"><strong>Standardizing WASI: A system interface to run WebAssembly outside the web</strong></a> <ul> <li>@alexcrichton already has a pull request to <a href="https://github.com/rust-lang/rust/pull/59464">add a <code class="highlighter-rouge">wasm32-unknown-wasi</code> target</a> for Rust!</li> </ul> </li> <li><code class="highlighter-rouge">RustVolley</code> is a reimplementation of the Blobby Volley 2 game in Rust and Wasm <ul> <li><a href="https://github.com/RustyVolley/RustyVolleySrc">Source</a></li> <li><a href="https://rustyvolley.github.io/WebDemo/">Live Demo</a></li> </ul> </li> <li><a href="https://blog.cloudflare.com/introducing-wrangler-cli/">CloudFlare’s new <code class="highlighter-rouge">wrangler</code> CLI tool lets you deploy Rust-generated Wasm on CloudFlare workers</a></li> <li><a href="https://www.fastly.com/blog/announcing-lucet-fastly-native-webassembly-compiler-runtime">Fastly open sources Lucet: a native WebAssembly compiler and runtime.</a> Its built with Rust on top of Cranelift and supports WASI.</li> </ul> <h2 id="updates-from-rustwasm">Updates from <a href="https://github.com/rustwasm"><code class="highlighter-rouge">rustwasm/*</code></a></h2> <p><a href="https://internals.rust-lang.org/t/welcome-pauan-to-the-rust-and-webassembly-domain-working-group-core-team/9707"><strong>🎉 Welcome @Pauan to the Rust and WebAssembly working group core team! 🎉</strong></a></p> <h3 id="rfcs">RFCs</h3> <h4 id="new-rfcs">New RFCs</h4> <p>None.</p> <h4 id="final-comment-period-rfcs">Final Comment Period RFCs</h4> <ul> <li><a href="https://github.com/rustwasm/rfcs/pull/9">Add an amendment to the RFC process</a></li> </ul> <h4 id="merged-rfcs">Merged RFCs</h4> <p>None.</p> <h3 id="working-group-meetings">Working Group Meetings</h3> <ul> <li><a href="https://www.youtube.com/watch?v=gaTwOc0eGb4">Watch the recording of this week’s working group meeting on YouTube</a></li> <li><a href="https://github.com/rustwasm/team/issues/264">Come join us at next week’s working group meeting!</a></li> </ul> <h3 id="gloo">Gloo</h3> <ul> <li><a href="https://rustwasm.github.io/2019/03/26/gloo-onion-layers.html"><strong>Gloo Update: Onion Layers, Timers, and Events</strong></a></li> <li>@Aehmlo <a href="https://github.com/rustwasm/gloo/pull/38">split up the <code class="highlighter-rouge">gloo_timers</code> crate’s public API</a> to use <code class="highlighter-rouge">callbacks</code> and <code class="highlighter-rouge">futures</code> submodules, as we collectively agreed upon in other issues.</li> <li>@cbrevik <a href="https://github.com/rustwasm/gloo/pull/32">implemented the <code class="highlighter-rouge">gloo_console_timer</code> crate,</a> which provides scoped closures and RAII-style helpers for working with <code class="highlighter-rouge">console.time</code> and <code class="highlighter-rouge">console.timeEnd</code>.</li> <li>@OddCoincidence <a href="https://github.com/rustwasm/gloo/pull/48">updated the <code class="highlighter-rouge">gloo_timers</code> internals</a> to use <code class="highlighter-rouge">wasm_bindgen::closures::Closure::once</code> for <code class="highlighter-rouge">setTimeout</code>.</li> <li>@RyLev added some initial <a href="https://github.com/rustwasm/gloo/pull/46">Azure Pipelines continuous integration tests</a> for Gloo.</li> <li>@David-OConnor added the <a href="https://github.com/rustwasm/gloo/pull/45">skeleton of an <code class="highlighter-rouge">mdbook</code> guide</a> for Gloo.</li> </ul> <h3 id="wasm-bindgen"><code class="highlighter-rouge">wasm-bindgen</code></h3> <ul> <li>@alexcrichton <a href="https://github.com/rustwasm/wasm-bindgen/pull/1384">tweaked the <code class="highlighter-rouge">no-modules</code> target’s generated JavaScript glue for instantiating Wasm modules</a> to support CloudFlare workers (and other environments where <code class="highlighter-rouge">x instanceof WebAssembly.Module</code> might fail, like across <code class="highlighter-rouge">&lt;iframe&gt;</code>s)</li> <li>@alexcrichton made it so that our emitted JS glue for reflecting Rust closures as JS functions will properly <a href="https://github.com/rustwasm/wasm-bindgen/pull/1385">detect and protect against use-after-free from the JS side.</a></li> <li>@alexcrichton fixed a bug where Rust structs exported as JS <a href="https://github.com/rustwasm/wasm-bindgen/pull/1383">didn’t always emit the JS classes glue in a deterministic order.</a></li> <li>@fitzgen <a href="https://github.com/rustwasm/wasm-bindgen/pull/1382">made the “without a JS bundler” example use <code class="highlighter-rouge">wasm-pack build --target web</code>,</a> now that its supported in the latest <code class="highlighter-rouge">wasm-pack</code> release.</li> <li>@alexcrichton <a href="https://github.com/rustwasm/wasm-bindgen/pull/1369">cleaned up the <code class="highlighter-rouge">wasm-bindgen</code> CLI’s options</a> to take <code class="highlighter-rouge">--target blah</code> instead of <code class="highlighter-rouge">--blah</code> (which still exist but are deprecated).</li> <li>@stevebob <a href="https://github.com/rustwasm/wasm-bindgen/pull/1358">enabled <code class="highlighter-rouge">mdbook</code>’s link checking tests for the <code class="highlighter-rouge">wasm-bindgen</code> guide</a> to our continuous integration tests.</li> <li>@alexcrichton <a href="https://github.com/rustwasm/wasm-bindgen/pull/1305">implemented <code class="highlighter-rouge">rustwasm/rfcs#8</code></a> to enable transitive crates dependencies on npm packages.</li> <li>@RReverser <a href="https://github.com/rustwasm/wasm-bindgen/pull/1403">added the <code class="highlighter-rouge">constructor</code> property</a> to <code class="highlighter-rouge">js_sys::Object</code>.</li> <li>@alexcrichton <a href="https://github.com/rustwasm/wasm-bindgen/pull/1401">fixed sending large <code class="highlighter-rouge">u32</code>s</a> from Wasm to JS.</li> <li>@RReverser <a href="https://github.com/rustwasm/wasm-bindgen/pull/1398">consistently exposed <code class="highlighter-rouge">is_like_none</code></a> for our generated JS glue, fixing a bug along the way.</li> <li>@RReverser <a href="https://github.com/rustwasm/wasm-bindgen/pull/1397">simplified the ABI representation</a> of <code class="highlighter-rouge">Option&lt;char&gt;</code>.</li> <li>@alexcrichton <a href="https://github.com/rustwasm/wasm-bindgen/pull/1395">migrated all the <code class="highlighter-rouge">wasm-bindgen-*</code> crates</a> to Rust 2018 edition.</li> <li>@RReverser <a href="https://github.com/rustwasm/wasm-bindgen/pull/1393">made iterating over JS objects via the JS iteration protocol faster</a> by removing redundant property string decoding.</li> <li>@RReverser <a href="https://github.com/rustwasm/wasm-bindgen/pull/1391">made a special version of passing strings from JS to Wasm</a> when we are targeting Node.js that is faster than using Node.js’s <code class="highlighter-rouge">TextEncoder</code> implementation.</li> </ul> <h3 id="wasm-pack"><code class="highlighter-rouge">wasm-pack</code></h3> <ul> <li>@alexcrichton <a href="https://github.com/rustwasm/wasm-pack/pull/598">fixed a panic</a> that could happen when installing the <code class="highlighter-rouge">wasm-bindgen</code> CLI tool.</li> </ul> <h2 id="requests-for-contribution">Requests for Contribution</h2> <p><strong>Want to get involved in Rust and WebAssembly? <a href="https://github.com/rustwasm/team/blob/master/README.md#get-involved">Join the Rust and WebAssembly working group!</a></strong></p> <h3 id="new-good-first-issues">New Good First Issues</h3> <ul> <li><a href="https://github.com/rustwasm/wasm-bindgen/issues/1390"><code class="highlighter-rouge">wasm-bindgen</code>: <code class="highlighter-rouge">.d.ts</code> file for <code class="highlighter-rouge">--web</code> target does not define the <code class="highlighter-rouge">init()</code> function</a></li> <li><a href="https://github.com/rustwasm/wasm-bindgen/issues/1387"><code class="highlighter-rouge">wasm-bindgen</code>: Closures should implement <code class="highlighter-rouge">std::fmt::Debug</code></a></li> <li><a href="https://github.com/rustwasm/gloo/issues/41">Gloo: Help ensure we have tracking issues on file for making utility crates for all Web platform features</a></li> </ul> <h3 id="new-help-wanted-issues">New “Help Wanted” Issues</h3> <ul> <li><a href="https://github.com/rustwasm/wasm-bindgen/issues/1399"><code class="highlighter-rouge">wasm-bindgen</code>: Closures should accept references as arguments</a></li> </ul>Hello and welcome to another issue of This Week in Rust and WebAssembly!Gloo Update: Onion Layers, Timers, and Events2019-03-26T00:00:00+00:002019-03-26T00:00:00+00:00https://rustwasm.github.io/2019/03/26/gloo-onion-layers<p>About two weeks ago, we <a href="https://rustwasm.github.io/2019/03/12/lets-build-gloo-together.html">kicked off</a> our effort to collectively build <a href="https://github.com/rustwasm/gloo">Gloo</a>, a modular toolkit for building fast and reliable Web apps and libraries with Rust and Wasm. We knew we wanted to explicitly cultivate the Rust and Wasm library ecosystem by spinning out reusable, standalone libraries: things that would help you out whether you were writing a green-field Web app in pure-Rust, building your own framework, or surgically inserting some Rust-generated Wasm into an existing JavaScript project. What was still fuzzy, and which we didn’t know yet, was <em>how</em> we were going design and expose these reusable bits.</p> <h2 id="onion-layered-apis">Onion-Layered APIs</h2> <p>I’m pleased to tell you that that after some collaborative discussion in issue threads, we’ve come up with a promising approach to designing Gloo APIs, and we’ve since formalized it a bit in <code class="highlighter-rouge">CONTRIBUTING.md</code>. I’ve nicknamed this approach “onion-layered” API design.</p> <p>Briefly, we want to build mid-level abstraction libraries on top of raw <code class="highlighter-rouge">-sys</code> bindings, build futures and streams integration on top of the mid-level APIs, and build high-level APIs on top of all that. But — crucially — every layer should be publicly exposed and reusable.</p> <p>While this approach to API design is certainly not novel, we want to very deliberately follow it so that we</p> <ul> <li>maximize reusability for the larger ecosystem, and</li> <li>exercise our mid-level APIs when building higher-level APIs, to ensure their generality and suitability for acting as a solid foundation.</li> </ul> <p>As we go through and examine each layer, I’ll use <a href="https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout">the <code class="highlighter-rouge">setTimeout</code> and <code class="highlighter-rouge">setInterval</code> Web APIs</a> as a running example.</p> <h2 id="the-core-wasm-bindgen-js-sys-and-web-sys">The Core: <code class="highlighter-rouge">wasm-bindgen</code>, <code class="highlighter-rouge">js-sys</code>, and <code class="highlighter-rouge">web-sys</code></h2> <p>The innermost layer are raw bindings built on top of <a href="https://rustwasm.github.io/2018/09/26/announcing-web-sys.html"><code class="highlighter-rouge">wasm-bindgen</code>, <code class="highlighter-rouge">js-sys</code> and <code class="highlighter-rouge">web-sys</code></a>. These bindings are fast, have a light code size foot print, and are future-compatible with <a href="https://github.com/WebAssembly/webidl-bindings/blob/9ada880991a26081279ee6b74e26502f5046a010/proposals/host-bindings/Overview.md">the host bindings proposal</a>.</p> <p>What they are <em>not</em> is super ergonomic to use all of the time. Using raw <code class="highlighter-rouge">web-sys</code> bindings directly can sometimes feel like making raw <code class="highlighter-rouge">libc</code> calls instead of leveraging Rust’s nice <code class="highlighter-rouge">std</code> abstractions.</p> <p>Here is doing some operation after a 500 millisecond timeout using raw <code class="highlighter-rouge">web-sys</code> bindings:</p> <div class="language-rust highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">use</span> <span class="nn">wasm_bindgen</span><span class="p">::{</span><span class="nn">closure</span><span class="p">::</span><span class="n">Closure</span><span class="p">,</span> <span class="n">JsCast</span><span class="p">};</span> <span class="c">// Create a Rust `FnOnce` closure that is exposed to JavaScript.</span> <span class="k">let</span> <span class="n">closure</span> <span class="o">=</span> <span class="nn">Closure</span><span class="p">::</span><span class="nf">once</span><span class="p">(</span><span class="k">move</span> <span class="p">||</span> <span class="p">{</span> <span class="nf">do_some_operation</span><span class="p">();</span> <span class="p">});</span> <span class="c">// Get the JavaScript function that reflects our Rust closure.</span> <span class="k">let</span> <span class="n">js_val</span> <span class="o">=</span> <span class="n">closure</span><span class="nf">.as_ref</span><span class="p">();</span> <span class="k">let</span> <span class="n">js_func</span> <span class="o">=</span> <span class="n">js_val</span><span class="py">.unchecked_ref</span><span class="p">::</span><span class="o">&lt;</span><span class="nn">js_sys</span><span class="p">::</span><span class="n">Function</span><span class="o">&gt;</span><span class="p">();</span> <span class="c">// Finally, call the `window.setTimeout` API.</span> <span class="k">let</span> <span class="n">timeout_id</span> <span class="o">=</span> <span class="nn">web_sys</span><span class="p">::</span><span class="nf">window</span><span class="p">()</span> <span class="nf">.expect</span><span class="p">(</span><span class="s">"should have a `window`"</span><span class="p">)</span> <span class="nf">.set_timeout_with_callback_and_timeout_and_arguments_0</span><span class="p">(</span><span class="n">js_func</span><span class="p">,</span> <span class="mi">500</span><span class="p">)</span> <span class="nf">.expect</span><span class="p">(</span><span class="s">"should set a timeout OK"</span><span class="p">);</span> <span class="c">// Then, if we ever decide we want to cancel the timeout, we do this:</span> <span class="nn">web_sys</span><span class="p">::</span><span class="nf">window</span><span class="p">()</span> <span class="nf">.expect</span><span class="p">(</span><span class="s">"should have a `window`"</span><span class="p">)</span> <span class="nf">.clear_timeout_with_handle</span><span class="p">(</span><span class="n">timeout_id</span><span class="p">);</span> </code></pre></div></div> <h2 id="the-callbacks-layer">The <code class="highlighter-rouge">callbacks</code> Layer</h2> <p>When we look at the raw <code class="highlighter-rouge">web-sys</code> usage, there is a bit of type conversion noise, some unfortunate method names, and a handful of <code class="highlighter-rouge">unwrap</code>s for ignoring edge-case scenarios where we prefer to fail loudly rather than limp along. We can clean all these things up with the first of our “mid-level” API layers, which in the case of timers is the <code class="highlighter-rouge">callbacks</code> module in the <code class="highlighter-rouge">gloo_timers</code> crate (which is also re-exported from the <code class="highlighter-rouge">gloo</code> umbrella crate as <code class="highlighter-rouge">gloo::timers</code>).</p> <p>The first “mid-level” API built on top of the <code class="highlighter-rouge">-sys</code> bindings exposes all the same functionality and the same design that the Web does, but uses proper Rust types. For example, at this layer, instead of taking untyped JavaScript functions with <code class="highlighter-rouge">js_sys::Function</code>, we take any <code class="highlighter-rouge">F: FnOnce()</code>. This layer is essentially the least opinionated direct API translation to Rust.</p> <div class="language-rust highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">use</span> <span class="nn">gloo</span><span class="p">::</span><span class="nn">timers</span><span class="p">::</span><span class="nn">callbacks</span><span class="p">::</span><span class="n">Timeout</span><span class="p">;</span> <span class="c">// Alternatively, we could use the `gloo_timers` crate without the rest of Gloo:</span> <span class="c">// use gloo_timers::callbacks::Timeout;</span> <span class="c">// Already, much nicer!</span> <span class="k">let</span> <span class="n">timeout</span> <span class="o">=</span> <span class="nn">Timeout</span><span class="p">::</span><span class="nf">new</span><span class="p">(</span><span class="mi">500</span><span class="p">,</span> <span class="k">move</span> <span class="p">||</span> <span class="p">{</span> <span class="nf">do_some_operation</span><span class="p">();</span> <span class="p">});</span> <span class="c">// If we ever decide we want to cancel our delayed operation, all we do is drop</span> <span class="c">// the `timeout` now:</span> <span class="k">drop</span><span class="p">(</span><span class="n">timeout</span><span class="p">);</span> <span class="c">// Or if we never want to cancel, we can use `forget`:</span> <span class="n">timeout</span><span class="nf">.forget</span><span class="p">();</span> </code></pre></div></div> <h2 id="layering-on-futures-and-streams">Layering on Futures and Streams</h2> <p>The next layer to add is integrating with popular traits and libraries in the Rust ecosystem, like <code class="highlighter-rouge">Future</code>s or <code class="highlighter-rouge">serde</code>. For our running <code class="highlighter-rouge">gloo::timers</code> example, this means we implement a <code class="highlighter-rouge">Future</code> backed by <code class="highlighter-rouge">setTimeout</code>, and a <code class="highlighter-rouge">Stream</code> implementation backed by <code class="highlighter-rouge">setInterval</code>.</p> <div class="language-rust highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">use</span> <span class="nn">futures</span><span class="p">::</span><span class="nn">prelude</span><span class="p">::</span><span class="o">*</span><span class="p">;</span> <span class="k">use</span> <span class="nn">gloo</span><span class="p">::</span><span class="nn">timers</span><span class="p">::</span><span class="nn">futures</span><span class="p">::</span><span class="n">TimeoutFuture</span><span class="p">;</span> <span class="c">// By using futures, we can use all the future combinator methods to build up a</span> <span class="c">// description of some asynchronous task.</span> <span class="k">let</span> <span class="n">my_future</span> <span class="o">=</span> <span class="nn">TimeoutFuture</span><span class="p">::</span><span class="nf">new</span><span class="p">(</span><span class="mi">500</span><span class="p">)</span> <span class="nf">.and_then</span><span class="p">(|</span><span class="n">_</span><span class="p">|</span> <span class="p">{</span> <span class="c">// Do some operation after 500 milliseconds...</span> <span class="nf">do_some_operation</span><span class="p">();</span> <span class="c">// and then wait another 500 milliseconds...</span> <span class="nn">TimeoutFuture</span><span class="p">::</span><span class="nf">new</span><span class="p">(</span><span class="mi">500</span><span class="p">)</span> <span class="p">})</span> <span class="nf">.map</span><span class="p">(|</span><span class="n">_</span><span class="p">|</span> <span class="p">{</span> <span class="c">// after which we do another operation!</span> <span class="nf">do_another_operation</span><span class="p">();</span> <span class="p">})</span> <span class="nf">.map_err</span><span class="p">(|</span><span class="n">err</span><span class="p">|</span> <span class="p">{</span> <span class="nf">handle_error</span><span class="p">(</span><span class="n">err</span><span class="p">);</span> <span class="p">});</span> <span class="c">// Spawn our future to run it!</span> <span class="nn">wasm_bindgen_futures</span><span class="p">::</span><span class="nf">spawn_local</span><span class="p">(</span><span class="n">my_future</span><span class="p">);</span> </code></pre></div></div> <p>Note that we use <code class="highlighter-rouge">futures</code> 0.1 for now, because we’ve fought tooth and nail to get the Wasm ecosystem on stable Rust, but as soon as the new <code class="highlighter-rouge">std::future::Future</code> design is stable, we plan to switch over. We are very excited for <code class="highlighter-rouge">async</code>/<code class="highlighter-rouge">await</code> as well!</p> <h2 id="more-layers">More Layers?</h2> <p>That’s all the layers we have for the <code class="highlighter-rouge">setTimeout</code> and <code class="highlighter-rouge">setInterval</code> APIs. Different Web APIs will have different sets of layers, and this is fine. Not every Web API uses callbacks, so it doesn’t make sense to always have a <code class="highlighter-rouge">callbacks</code> module in every Gloo crate. The important part is that we are actively identifying layers, making them public and reusable, and building higher-level layers on top of lower-level layers.</p> <p>We will likely add even higher-level layers to other Web APIs where it makes sense. For example, the <a href="https://github.com/rustwasm/gloo/issues/47">File API</a>’s <code class="highlighter-rouge">FileReader</code> interface exposes methods that you shouldn’t call until after certain events have fired, and any attempt to call them earlier will throw. We can codify this as <a href="https://github.com/fitzgen/state_machine_future">a state machine-based <code class="highlighter-rouge">Future</code></a>, that doesn’t even give you the ability to call those methods until after the relevant events have fired and the state machine reaches a certain state. Leveraging types at compile time for ergonomics and correctness!</p> <p>Another future direction is adding more integration layers with more parts of the larger Rust crates ecosystem. For example, adding functional reactive programming-style layers via <a href="https://github.com/rustwasm/gloo/issues/33">the <code class="highlighter-rouge">futures-signals</code> crate</a> which is also used by the <a href="https://github.com/Pauan/rust-dominator"><code class="highlighter-rouge">dominator</code></a> framework.</p> <h2 id="events">Events</h2> <p>One of the active bits of design work going on in Gloo right now is how to craft our event targets and listeners layer. Events are used across most of the Web APIs, so it is very important we get this design right, as it will sit underneath many of our other crates. While we haven’t 100% nailed down the design yet, I really like where we are headed.</p> <p>On top of <a href="https://docs.rs/web-sys/0.3.17/web_sys/struct.Event.html"><code class="highlighter-rouge">web_sys::Event</code></a> and <a href="https://docs.rs/web-sys/0.3.17/web_sys/struct.EventTarget.html#method.add_event_listener_with_callback"><code class="highlighter-rouge">web_sys::EventTarget::add_event_listener_with_callback</code></a>, we are building a layer for <a href="https://github.com/rustwasm/gloo/issues/30">adding and removing event listeners</a> and managing their lifetimes from Rust via RAII-style automatic cleanup upon drop.</p> <p>We can use this API to make idiomatic Rust types that attach event listeners that automatically get removed from the DOM when the type is dropped:</p> <div class="language-rust highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">use</span> <span class="nn">futures</span><span class="p">::</span><span class="nn">sync</span><span class="p">::</span><span class="n">oneshot</span><span class="p">;</span> <span class="k">use</span> <span class="nn">gloo</span><span class="p">::</span><span class="nn">events</span><span class="p">::</span><span class="n">EventListener</span><span class="p">;</span> <span class="c">// A prompt for the user.</span> <span class="k">pub</span> <span class="k">struct</span> <span class="n">Prompt</span> <span class="p">{</span> <span class="n">receiver</span><span class="p">:</span> <span class="nn">oneshot</span><span class="p">::</span><span class="n">Receiver</span><span class="o">&lt;</span><span class="nb">String</span><span class="o">&gt;</span><span class="p">,</span> <span class="c">// Automatically removed from the DOM on drop!</span> <span class="n">listener</span><span class="p">:</span> <span class="n">EventListener</span><span class="p">,</span> <span class="p">}</span> <span class="k">impl</span> <span class="n">Prompt</span> <span class="p">{</span> <span class="k">pub</span> <span class="k">fn</span> <span class="nf">new</span><span class="p">()</span> <span class="k">-&gt;</span> <span class="n">Prompt</span> <span class="p">{</span> <span class="c">// Create an `&lt;input&gt;` to prompt the user for something and attach it to the DOM.</span> <span class="k">let</span> <span class="n">input</span><span class="p">:</span> <span class="nn">web_sys</span><span class="p">::</span><span class="n">HtmlInputElement</span> <span class="o">=</span> <span class="nd">unimplemented!</span><span class="p">();</span> <span class="c">// Create a oneshot channel for sending/receiving the user's input.</span> <span class="k">let</span> <span class="p">(</span><span class="n">sender</span><span class="p">,</span> <span class="n">receiver</span><span class="p">)</span> <span class="o">=</span> <span class="nn">oneshot</span><span class="p">::</span><span class="nf">channel</span><span class="p">();</span> <span class="c">// Attach an event listener to the input element.</span> <span class="k">let</span> <span class="n">listener</span> <span class="o">=</span> <span class="nn">EventListener</span><span class="p">::</span><span class="nf">new</span><span class="p">(</span><span class="o">&amp;</span><span class="n">input</span><span class="p">,</span> <span class="s">"input"</span><span class="p">,</span> <span class="k">move</span> <span class="p">|</span><span class="n">_event</span><span class="p">:</span> <span class="o">&amp;</span><span class="nn">web_sys</span><span class="p">::</span><span class="n">Event</span><span class="p">|</span> <span class="p">{</span> <span class="c">// Get the input element's value.</span> <span class="k">let</span> <span class="n">value</span> <span class="o">=</span> <span class="n">input</span><span class="nf">.value</span><span class="p">();</span> <span class="c">// Send the input value over the oneshot channel.</span> <span class="n">sender</span><span class="nf">.send</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> <span class="nf">.expect_throw</span><span class="p">(</span> <span class="s">"receiver should not be dropped without first removing DOM listener"</span> <span class="p">);</span> <span class="p">});</span> <span class="n">Prompt</span> <span class="p">{</span> <span class="n">receiver</span><span class="p">,</span> <span class="n">listener</span><span class="p">,</span> <span class="p">}</span> <span class="p">}</span> <span class="p">}</span> <span class="c">// A `Prompt` is also a future, that resolves after the user input!</span> <span class="k">impl</span> <span class="n">Future</span> <span class="k">for</span> <span class="n">Prompt</span> <span class="p">{</span> <span class="k">type</span> <span class="n">Item</span> <span class="o">=</span> <span class="nb">String</span><span class="p">;</span> <span class="k">type</span> <span class="n">Error</span> <span class="o">=</span> <span class="p">();</span> <span class="k">fn</span> <span class="nf">poll</span><span class="p">(</span><span class="o">&amp;</span><span class="k">mut</span> <span class="k">self</span><span class="p">)</span> <span class="k">-&gt;</span> <span class="n">Poll</span><span class="o">&lt;</span><span class="nn">Self</span><span class="p">::</span><span class="n">Item</span><span class="p">,</span> <span class="nn">Self</span><span class="p">::</span><span class="n">Error</span><span class="o">&gt;</span> <span class="p">{</span> <span class="k">self</span><span class="py">.receiver</span> <span class="nf">.poll</span><span class="p">()</span> <span class="nf">.map_err</span><span class="p">(|</span><span class="n">_</span><span class="p">|</span> <span class="p">{</span> <span class="nd">unreachable!</span><span class="p">(</span> <span class="s">"we don't drop the sender without either sending a value or dropping the whole Prompt"</span> <span class="p">)</span> <span class="p">})</span> <span class="p">}</span> <span class="p">}</span> </code></pre></div></div> <p>On top of that layer, we are using Rust’s trait system to design <a href="https://github.com/rustwasm/gloo/issues/43">a higher-level, static events API</a> that will make the events casting safe and statically-checked, and make sure you don’t have typos in the event types that you listen to:</p> <div class="language-rust highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">use</span> <span class="nn">gloo</span><span class="p">::</span><span class="nn">events</span><span class="p">::{</span><span class="n">ClickEvent</span><span class="p">,</span> <span class="n">on</span><span class="p">};</span> <span class="c">// Get an event target from somewhere.</span> <span class="k">let</span> <span class="n">target</span><span class="p">:</span> <span class="nn">web_sys</span><span class="p">::</span><span class="n">EventTarget</span> <span class="o">=</span> <span class="nd">unimplemented!</span><span class="p">();</span> <span class="c">// Listen to the "click" event, know that you didn't misspell the event as</span> <span class="c">// "clik", and also get a nicer event type!</span> <span class="k">let</span> <span class="n">click_listener</span> <span class="o">=</span> <span class="nf">on</span><span class="p">(</span><span class="o">&amp;</span><span class="n">target</span><span class="p">,</span> <span class="k">move</span> <span class="p">|</span><span class="n">e</span><span class="p">:</span> <span class="o">&amp;</span><span class="n">ClickEvent</span><span class="p">|</span> <span class="p">{</span> <span class="c">// The `ClickEvent` type has nice getters for the `MouseEvent` that</span> <span class="c">// `"click"` events are guaranteed to yield. No need to dynamically cast</span> <span class="c">// an `Event` to a `MouseEvent`.</span> <span class="k">let</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span> <span class="o">=</span> <span class="n">event</span><span class="nf">.mouse_position</span><span class="p">();</span> <span class="c">// ...</span> <span class="p">});</span> </code></pre></div></div> <p>These event APIs are still works in progress and have some kinks to work out, but I’m very excited for them, and we hope to get a lot of mileage out of them as we build other Gloo crates that internally use them.</p> <h2 id="get-involved">Get Involved!</h2> <p>Let’s build Gloo together! Want to get involved?</p> <ul> <li><a href="https://discord.gg/rust-lang">Join the <code class="highlighter-rouge">#WG-wasm</code> channel on the Rust Discord server!</a></li> <li><a href="https://github.com/rustwasm/gloo">Follow the <code class="highlighter-rouge">rustwasm/gloo</code> repository on GitHub and check out its <code class="highlighter-rouge">CONTRIBUTING.md</code></a></li> </ul>Nick FitzgeraldAbout two weeks ago, we kicked off our effort to collectively build Gloo, a modular toolkit for building fast and reliable Web apps and libraries with Rust and Wasm. We knew we wanted to explicitly cultivate the Rust and Wasm library ecosystem by spinning out reusable, standalone libraries: things that would help you out whether you were writing a green-field Web app in pure-Rust, building your own framework, or surgically inserting some Rust-generated Wasm into an existing JavaScript project. What was still fuzzy, and which we didn’t know yet, was how we were going design and expose these reusable bits.This Week in Rust and WebAssembly 142019-03-21T00:00:00+00:002019-03-21T00:00:00+00:00https://rustwasm.github.io/2019/03/21/this-week-in-rust-and-wasm-014<p>Hello and welcome to another issue of <em>This Week in Rust and WebAssembly</em>!</p> <p><a href="https://rust-lang.org">Rust</a> is a systems language pursuing the trifecta: safety, concurrency, and speed.</p> <p><a href="http://webassembly.org">WebAssembly</a> is a stack-based virtual machine and instruction set. It is fast, safe, portable, and part of the open Web platform. By compiling to WebAssembly, we can run Rust code on the Web!</p> <p>This is a weekly summary of Rust and WebAssembly’s progress and community.</p> <p>Did we miss something? Tweet to us at <a href="https://twitter.com/rustwasm">@rustwasm</a> or <a href="https://github.com/rustwasm/rustwasm.github.io">send us a pull request</a>.</p> <p><strong>Want to get involved in Rust and WebAssembly? <a href="https://github.com/rustwasm/team/blob/master/README.md#get-involved">Join the Rust and WebAssembly working group!</a></strong></p> <h2 id="news-and-blog-posts-from-around-the-web">News and Blog Posts from Around the Web</h2> <p><em>Want to make sure something ends up on this list next time we publish an issue? <a href="https://github.com/rustwasm/team/issues/79">Leave a comment on this issue.</a></em></p> <ul> <li><a href="https://hacks.mozilla.org/2019/03/fast-bump-allocated-virtual-doms-with-rust-and-wasm/"><strong>Fast, Bump-Allocated Virtual DOMs with Rust and Wasm</strong></a></li> <li><a href="https://github.com/David-OConnor/seed/blob/master/CHANGELOG.md#v030">Version 0.3 of the <code class="highlighter-rouge">seed</code> framework was released</a></li> <li><a href="https://github.com/web-dom/web-dom"><code class="highlighter-rouge">web-dom</code> is an alternative way to access the DOM from Rust</a></li> <li><a href="https://twitter.com/ensembl/status/1106140169575514113">Ensembl 2020 (a genome browser) will use Rust and Wasm</a></li> <li><a href="https://users.rust-lang.org/t/another-small-step-to-wasm-compatibility-actix-actors-in-the-browser/26318">The <code class="highlighter-rouge">actix</code> project is working on getting their actors running as Wasm on the Web</a></li> <li><a href="https://twitter.com/alesgeno/status/1107662063168614400">Demo: a real-time pitch detector Web application (and reusable library crate!) made with Rust and Wasm</a></li> <li><a href="https://rust.godbolt.org/z/PZqG56">The Godbolt Compiler Explorer can show Wasm disassembly, with color-coded highlighting showing which Rust source text compiled into which Wasm instructions</a></li> </ul> <h2 id="updates-from-rustwasm">Updates from <a href="https://github.com/rustwasm"><code class="highlighter-rouge">rustwasm/*</code></a></h2> <h3 id="rfcs">RFCs</h3> <h4 id="new-rfcs">New RFCs</h4> <ul> <li><a href="https://github.com/rustwasm/rfcs/pull/10">Add <code class="highlighter-rouge">watch</code> and <code class="highlighter-rouge">serve</code> subcommands to <code class="highlighter-rouge">wasm-pack</code></a></li> </ul> <h4 id="final-comment-period-rfcs">Final Comment Period RFCs</h4> <p>None.</p> <h4 id="merged-rfcs">Merged RFCs</h4> <ul> <li><a href="https://github.com/rustwasm/rfcs/pull/7"><strong>2019 Roadmap 🎉</strong></a></li> <li><a href="https://github.com/rustwasm/rfcs/pull/8">Enable depending on NPM packages</a></li> </ul> <h3 id="working-group-meetings">Working Group Meetings</h3> <ul> <li><a href="https://youtu.be/uYySHPCuLz0">Watch the recording of this week’s working group meeting on YouTube</a></li> <li><a href="https://github.com/rustwasm/team/issues/262">Come join us at next week’s working group meeting!</a></li> </ul> <h3 id="gloo">Gloo</h3> <ul> <li><a href="https://rustwasm.github.io/2019/03/12/lets-build-gloo-together.html">Gloo is the modular toolkit we decided to collectively build in our 2019 roadmap.</a> We’ve been having lots of good discussion about scope and API design in issue threads! (Not doing lots of PRs quite yet.)</li> <li>@OddCoincidence <a href="https://github.com/rustwasm/gloo/pull/24">added support for <code class="highlighter-rouge">setInterval</code></a> to <code class="highlighter-rouge">gloo-timers</code>.</li> </ul> <h3 id="rustwasmgithubio"><code class="highlighter-rouge">rustwasm.github.io</code></h3> <ul> <li>@DebugSteven <a href="https://github.com/rustwasm/rustwasm.github.io/pull/43">removed some unused CSS rules</a> from our Website’s stylesheets.</li> </ul> <h3 id="rust-webpack-template"><code class="highlighter-rouge">rust-webpack-template</code></h3> <ul> <li>@alexcrichton <a href="https://github.com/rustwasm/rust-webpack-template/pull/120">upgraded the template</a> to the Rust 2018 edition.</li> </ul> <h3 id="twiggy">Twiggy</h3> <ul> <li>@data-pup <a href="https://github.com/rustwasm/twiggy/pull/265">upgraded Twiggy</a> to the Rust 2018 edition.</li> <li>@data-pup <a href="https://github.com/rustwasm/twiggy/pull/268">added more tests</a> for the <code class="highlighter-rouge">twiggy diff</code> subcommand.</li> </ul> <h3 id="wasm-bindgen"><code class="highlighter-rouge">wasm-bindgen</code></h3> <ul> <li><a href="https://github.com/rustwasm/wasm-bindgen/blob/master/CHANGELOG.md#0239"><strong>We released <code class="highlighter-rouge">wasm-bindgen</code> version 0.2.39! 🎉</strong></a></li> <li>@c410-f3r made <code class="highlighter-rouge">wasm-bindgen</code>’s generated TypeScript interfaces’ functions’ argument names be <a href="https://github.com/rustwasm/wasm-bindgen/pull/1344">preserved from the Rust source</a> instead of being generated symbols.</li> <li>@ibaryshnikov <a href="https://github.com/rustwasm/wasm-bindgen/pull/1336">cleaned up</a> our Web GL example.</li> <li>@nstoddard <a href="https://github.com/rustwasm/wasm-bindgen/pull/1333">added immutability whitelisting</a> for <code class="highlighter-rouge">Uint8Array</code>, <code class="highlighter-rouge">ArrayBufferView</code>, and <code class="highlighter-rouge">BufferSource</code>.</li> <li>@RReverser <a href="https://github.com/rustwasm/wasm-bindgen/pull/1372">fixed some copy-paste errors</a> in documentation for <code class="highlighter-rouge">Int32Array</code> and <code class="highlighter-rouge">Uint32Array</code></li> <li>@RReverser <a href="https://github.com/rustwasm/wasm-bindgen/pull/1371">cleaned up and de-duplicated our binding definitions</a> to the different kinds of typed arrays!</li> <li>@c410-f3r <a href="https://github.com/rustwasm/wasm-bindgen/pull/1356">expanded the testing</a> of our emitted TypeScript interface definitions.</li> <li>@alexcrichton <a href="https://github.com/rustwasm/wasm-bindgen/pull/1353">added the <code class="highlighter-rouge">#[wasm_bindgen(raw_module = "...")]</code> attribute</a> to the <code class="highlighter-rouge">wasm-bindgen</code> proc-macro.</li> <li>@konradsz <a href="https://github.com/rustwasm/wasm-bindgen/pull/1351">fixed the number-slices example’s JS imports.</a></li> <li>@alexlapa <a href="https://github.com/rustwasm/wasm-bindgen/pull/1350">enabled passing optional imported <code class="highlighter-rouge">enum</code>s</a> over the FFI boundary.</li> </ul> <h3 id="wasm-pack"><code class="highlighter-rouge">wasm-pack</code></h3> <ul> <li><a href="https://github.com/rustwasm/wasm-pack/blob/master/CHANGELOG.md#%EF%B8%8F-070"><strong>We released <code class="highlighter-rouge">wasm-pack</code> version 0.7.0! 🎉</strong></a></li> <li>@alexcrichton <a href="https://github.com/rustwasm/wasm-pack/pull/567">added support for the <code class="highlighter-rouge">web</code> target</a> to <code class="highlighter-rouge">wasm-pack</code>. This target uses browsers’ native support for ES modules, and doesn’t require the use of a JS bundler.</li> <li>@alexcrichton <a href="https://github.com/rustwasm/wasm-pack/pull/547">started migrating <code class="highlighter-rouge">wasm-pack</code>’s CLI output</a> towards our 1.0 vision for <code class="highlighter-rouge">wasm-pack</code> output. Notably, <code class="highlighter-rouge">cargo build</code>’s colors and progress bar should work now.</li> <li>@alexcrichton <a href="https://github.com/rustwasm/wasm-pack/pull/590">added a smorgasbord</a> of docs improvements.</li> <li>@drager <a href="https://github.com/rustwasm/wasm-pack/pull/552">added support for non-<code class="highlighter-rouge">rustup</code>-based Rust development environments</a> to <code class="highlighter-rouge">wasm-pack</code>.</li> <li>@ashleygwilliams <a href="https://github.com/rustwasm/wasm-pack/pull/576">added a quickstart doc page</a> for using <code class="highlighter-rouge">wasm-pack</code> with Webpack.</li> </ul> <h3 id="wasm-pack-template"><code class="highlighter-rouge">wasm-pack-template</code></h3> <ul> <li>@alexcrichton <a href="https://github.com/rustwasm/wasm-pack-template/pull/37">upgraded the template</a> to the Rust 2018 edition.</li> </ul> <h2 id="requests-for-contribution">Requests for Contribution</h2> <p><strong>Want to get involved in Rust and WebAssembly? <a href="https://github.com/rustwasm/team/blob/master/README.md#get-involved">Join the Rust and WebAssembly working group!</a></strong></p> <ul> <li><a href="https://rustwasm.github.io/2019/03/12/lets-build-gloo-together.html"><strong>Let’s Build Gloo Together</strong></a></li> <li><a href="https://github.com/issues?q=is%3Aopen+is%3Aissue+user%3Arustwasm+archived%3Afalse+label%3A%22good+first+issue%22">All issues labeled “good first issue” in the <code class="highlighter-rouge">rustwasm/*</code> repositories</a></li> <li><a href="https://github.com/issues?q=is%3Aopen+is%3Aissue+user%3Arustwasm+archived%3Afalse+label%3A%22help+wanted%22">All issues labeled “help wanted” in the <code class="highlighter-rouge">rustwasm/*</code> repositories</a></li> </ul> <h3 id="new-good-first-issues">New Good First Issues</h3> <ul> <li><a href="https://github.com/rustwasm/gloo/issues/36">Gloo: Make the timers crate follow submodule design</a></li> </ul>Hello and welcome to another issue of This Week in Rust and WebAssembly!Let’s Build Gloo Together2019-03-12T00:00:00+00:002019-03-12T00:00:00+00:00https://rustwasm.github.io/2019/03/12/lets-build-gloo-together<p>The Rust and WebAssembly domain working group wants to cultivate a stable, batteries-available, and production-ready ecosystem for <a href="https://github.com/rustwasm/rfcs/pull/7">Rust and Wasm development in 2019</a>.</p> <p>To further that goal, we are creating <a href="https://github.com/rustwasm/gloo">Gloo</a>, a modular toolkit for building both:</p> <ul> <li> <p>small, targeted Wasm modules that integrate into a larger JavaScript system, and</p> </li> <li> <p>whole Web applications written in Rust.</p> </li> </ul> <p>Gloo’s goals for Wasm are similar to what the Async Ecosystem working group’s <a href="https://rustasync.github.io/team/2018/09/11/tide.html">Tide</a> project intends to do for server-side Web development:</p> <blockquote> <p>The name “Tide” refers to “a rising tide lifts all boats”; the intent is to improve sharing, compatibility, and improvements across all web development and frameworks in Rust.</p> </blockquote> <h2 id="the-utility-high-level-libraries-and-frameworks-provide">The Utility High-Level Libraries and Frameworks Provide</h2> <p>We use high-level libraries and frameworks instead of using Web APIs directly because we want abstractions with which we can naturally express ourselves. We outsource non-business logic concerns so that we can create more robust libraries and applications more quickly than we otherwise would. For example, the desires people might have include:</p> <ul> <li> <p>They prefer describing how they want the DOM to look like right now, rather than enumerating a list of modifications that will transform its current state into their desired state. Therefore, they use an immediate-mode virtual DOM library.</p> </li> <li> <p>They prefer thinking in terms of Rust types, not about the raw, serialized bytes in a <code class="highlighter-rouge">fetch</code>ed HTTP response body or about object stores in Indexed DB. Therefore, they use <code class="highlighter-rouge">derive</code>-based serialization and deserialization with <code class="highlighter-rouge">serde</code>.</p> </li> </ul> <p>There are many different ways to approach high-level APIs, and people have lots of differing opinions about which way is best! Designing these APIs well is difficult: we have correctness, ergonomic, and performance concerns.</p> <h2 id="how-gloo-fits-in">How Gloo Fits In</h2> <p>Gloo aims to be both a collection of small, focused utility crates and an umbrella crate that pulls all the utilities together into a single package.</p> <p>Our goals with Gloo are:</p> <ul> <li> <p><strong>To bolster the Rust and WebAssembly crates ecosystem.</strong> Pick and choose utility crates even if you aren’t using the whole umbrella Gloo crate, or if you are using some other Rust and Wasm framework. We have some crates like this today — for example <a href="https://crates.io/crates/console_log">the <code class="highlighter-rouge">console_log</code> crate</a> — but we would like to intentionally grow more shared utility crates across the ecosystem.</p> </li> <li> <p><strong>To wrap these utilities up in an umbrella crate so that your new project can hit the ground running.</strong> This umbrella crate will be a thin wrapper around the utility crates, and provides defaults wherever multiple (perhaps opinionated) choices exist. To keep the umbrella crate small, we should be constantly pulling code out into new shared, utility crates. For the more opinionated bits, like virtual DOM rendering or web components, the umbrella crate should prefer interfaces over implementations, so that different implementations with different approaches are swap-able.</p> </li> </ul> <p>Gloo is far from ready right now! The project has only just begun. But we want to build Gloo as a collective and in an open way, so we are announcing it early and inviting you to come help us design and build it.</p> <p>Want to get involved?</p> <ul> <li><a href="https://discord.gg/rust-lang">Join the <code class="highlighter-rouge">#WG-wasm</code> channel on the Rust Discord server!</a></li> <li><a href="https://github.com/rustwasm/gloo">Follow the <code class="highlighter-rouge">rustwasm/gloo</code> repository on GitHub</a></li> </ul> <h2 id="where-were-starting">Where We’re Starting</h2> <p><a href="https://rustwasm.github.io/2019/02/13/this-week-in-rust-and-wasm-010.html#wasm-at-the-2019-rust-all-hands">At the 2019 Rust All Hands meeting in Berlin</a>, we found that it was useful to categorize Web libraries by whether they were opinionated or not. We all want idiomatic-Rust wrapper crates around raw <code class="highlighter-rouge">web-sys</code> timers and <code class="highlighter-rouge">requestAnimationFrame</code> etc, and there isn’t a <em>whole lot</em> of design work that needs to happen for this. For many of these kinds of crates, we are ready to dive into implementation. On the other hand, for the more opinionated bits, like virtual DOMs and state management, we need to do exploratory design work before committing to a particular approach.</p> <p>We’ll start exploring the design space of the latter group in a series of follow up blog posts. In the meantime, if you want to get involved, start hacking on some of the utility crates, or brainstorm about designs, then <a href="https://github.com/rustwasm/gloo/issues">check out some of the issues</a> on Gloo’s GitHub repository.</p>Nick FitzgeraldThe Rust and WebAssembly domain working group wants to cultivate a stable, batteries-available, and production-ready ecosystem for Rust and Wasm development in 2019.This Week in Rust and WebAssembly 132019-03-07T00:00:00+00:002019-03-07T00:00:00+00:00https://rustwasm.github.io/2019/03/07/this-week-in-rust-and-wasm-013<p>Hello and welcome to another issue of <em>This Week in Rust and WebAssembly</em>!</p> <p><a href="https://rust-lang.org">Rust</a> is a systems language pursuing the trifecta: safety, concurrency, and speed.</p> <p><a href="http://webassembly.org">WebAssembly</a> is a stack-based virtual machine and instruction set. It is fast, safe, portable, and part of the open Web platform. By compiling to WebAssembly, we can run Rust code on the Web!</p> <p>This is a weekly summary of Rust and WebAssembly’s progress and community.</p> <p>Did we miss something? Tweet to us at <a href="https://twitter.com/rustwasm">@rustwasm</a> or <a href="https://github.com/rustwasm/rustwasm.github.io">send us a pull request</a>.</p> <p><strong>Want to get involved in Rust and WebAssembly? <a href="https://github.com/rustwasm/team/blob/master/README.md#get-involved">Join the Rust and WebAssembly working group!</a></strong></p> <!-- TODO: check recent r/rust and users.rust-lang.org posts for "wasm" and "webassembly": --> <!-- https://twitter.com/rustwasm --> <h2 id="news-and-blog-posts-from-around-the-web">News and Blog Posts from Around the Web</h2> <p><em>Want to make sure something ends up on this list next time we publish an issue? <a href="https://github.com/rustwasm/team/issues/79">Leave a comment on this issue.</a></em></p> <ul> <li><a href="https://prestonrichey.com/blog/react-rust-wasm/">Up and Running with React, Rust, and Wasm</a></li> <li>The Tao of Rust is a book about Rust that was originally published in China. It has a WebAssembly section, and is <a href="https://www.reddit.com/r/rust/comments/ax86y1/introducing_the_book_the_tao_of_rust/">getting translated into English</a>!</li> <li><a href="https://github.com/wasm-network/tweek-rust">Tweek is a new tween animation kit for Rust that supports Wasm</a></li> </ul> <h2 id="updates-from-rustwasm">Updates from <a href="https://github.com/rustwasm"><code class="highlighter-rouge">rustwasm/*</code></a></h2> <h3 id="rfcs">RFCs</h3> <h4 id="new-rfcs">New RFCs</h4> <ul> <li><a href="https://github.com/rustwasm/rfcs/pull/9">Amend the RFC process</a></li> </ul> <h4 id="final-comment-period-rfcs">Final Comment Period RFCs</h4> <p>None.</p> <h4 id="merged-rfcs">Merged RFCs</h4> <ul> <li><a href="https://github.com/rustwasm/rfcs/pull/6">Add support for local JavaScript snippets to <code class="highlighter-rouge">wasm-bindgen</code></a></li> </ul> <h3 id="working-group-meetings">Working Group Meetings</h3> <ul> <li><a href="https://youtu.be/sQE6IjnzwS8">Watch the recording of this week’s working group meeting on YouTube</a></li> <li><a href="https://github.com/rustwasm/team/issues/260">Come join us at next week’s working group meeting!</a></li> </ul> <h3 id="rustwasmgithubio"><code class="highlighter-rouge">rustwasm.github.io</code></h3> <ul> <li>@DebugSteven and @alexcrichton <a href="https://github.com/rustwasm/rustwasm.github.io/pull/41">aggregated the Rust and WebAssembly book, the <code class="highlighter-rouge">wasm-bindgen</code> guide, and the <code class="highlighter-rouge">wasm-pack</code> guide into a single bookshelf</a>, where all of our docs can be found in one place!</li> </ul> <h3 id="twiggy"><code class="highlighter-rouge">twiggy</code></h3> <ul> <li>@data-pup <a href="https://github.com/rustwasm/twiggy/pull/253">added <code class="highlighter-rouge">rustfmt</code> and <code class="highlighter-rouge">clippy</code> integration</a> into Twiggy’s CI setup.</li> <li>@sepiropht <a href="https://github.com/rustwasm/twiggy/pull/260">improved Twiggy’s detection</a> of what kind of binary it is looking at when there is no file extension.</li> </ul> <h3 id="walrus"><code class="highlighter-rouge">walrus</code></h3> <ul> <li>@data-pup <a href="https://github.com/rustwasm/walrus/pull/64">fixed the wasm round-tripping tests</a> for the latest release of the <code class="highlighter-rouge">webassembly/wabt</code> tools.</li> <li>@alexcrichton <a href="https://github.com/rustwasm/walrus/pull/66">added support</a> for the WebAssembly SIMD proposal to <code class="highlighter-rouge">walrus</code>.</li> </ul> <h3 id="wasm-bindgen"><code class="highlighter-rouge">wasm-bindgen</code></h3> <ul> <li>@fitzgen <a href="https://github.com/rustwasm/wasm-bindgen/pull/1281">added support for <code class="highlighter-rouge">FnOnce</code> functions</a> to <code class="highlighter-rouge">wasm_bindgen::Closure</code>.</li> <li>@c410-f3r <a href="https://github.com/rustwasm/wasm-bindgen/pull/1331">fixed <code class="highlighter-rouge">wasm-bindgen</code> compilation</a> when the <code class="highlighter-rouge">"extra-traits"</code> feature was enabled.</li> <li>@alexcrichton <a href="https://github.com/rustwasm/wasm-bindgen/pull/1295">implemented the local JavaScript snippets RFC</a> for <code class="highlighter-rouge">wasm-bindgen</code>.</li> <li>@Vlad-Scherbina <a href="https://github.com/rustwasm/wasm-bindgen/pull/1330">fixed a bug</a> where if the directory specified by <code class="highlighter-rouge">--out-dir</code> does not exist, then running the <code class="highlighter-rouge">wasm-bindgen</code> CLI would fail.</li> <li>@alexcrichton <a href="https://github.com/rustwasm/wasm-bindgen/pull/1314">added testing</a> of <code class="highlighter-rouge">wasm-bindgen</code>’s generated TypeScript interface definition files in CI.</li> </ul> <h3 id="wasm-pack"><code class="highlighter-rouge">wasm-pack</code></h3> <ul> <li>@drager <a href="https://github.com/rustwasm/wasm-pack/pull/517">wrote a test suite</a> for <code class="highlighter-rouge">wasm-pack</code>’s binary installation utility crate.</li> </ul> <h2 id="requests-for-contribution">Requests for Contribution</h2> <p><strong>Want to get involved in Rust and WebAssembly? <a href="https://github.com/rustwasm/team/blob/master/README.md#get-involved">Join the Rust and WebAssembly working group!</a></strong></p> <ul> <li><a href="https://github.com/issues?q=is%3Aopen+is%3Aissue+user%3Arustwasm+archived%3Afalse+label%3A%22good+first+issue%22">All issues labeled “good first issue” in the <code class="highlighter-rouge">rustwasm/*</code> repositories</a></li> <li><a href="https://github.com/issues?q=is%3Aopen+is%3Aissue+user%3Arustwasm+archived%3Afalse+label%3A%22help+wanted%22">All issues labeled “help wanted” in the <code class="highlighter-rouge">rustwasm/*</code> repositories</a></li> </ul>Hello and welcome to another issue of This Week in Rust and WebAssembly!This Week in Rust and WebAssembly 122019-02-28T00:00:00+00:002019-02-28T00:00:00+00:00https://rustwasm.github.io/2019/02/28/this-week-in-rust-and-wasm-012<p>Hello and welcome to another issue of <em>This Week in Rust and WebAssembly</em>!</p> <p><a href="https://rust-lang.org">Rust</a> is a systems language pursuing the trifecta: safety, concurrency, and speed.</p> <p><a href="http://webassembly.org">WebAssembly</a> is a stack-based virtual machine and instruction set. It is fast, safe, portable, and part of the open Web platform. By compiling to WebAssembly, we can run Rust code on the Web!</p> <p>This is a weekly summary of Rust and WebAssembly’s progress and community.</p> <p>Did we miss something? Tweet to us at <a href="https://twitter.com/rustwasm">@rustwasm</a> or <a href="https://github.com/rustwasm/rustwasm.github.io">send us a pull request</a>.</p> <p><strong>Want to get involved in Rust and WebAssembly? <a href="https://github.com/rustwasm/team/blob/master/README.md#get-involved">Join the Rust and WebAssembly working group!</a></strong></p> <!-- TODO: check recent r/rust and users.rust-lang.org posts for "wasm" and "webassembly": --> <!-- https://twitter.com/rustwasm --> <h2 id="news-and-blog-posts-from-around-the-web">News and Blog Posts from Around the Web</h2> <p><em>Want to make sure something ends up on this list next time we publish an issue? <a href="https://github.com/rustwasm/team/issues/79">Leave a comment on this issue.</a></em></p> <ul> <li><a href="https://developers.google.com/web/updates/2019/02/hotpath-with-wasm">Replacing a hot path in your app’s JavaScript with WebAssembly.</a> The article compares versions written in Rust, C/C++, and AssemblyScript.</li> <li><a href="https://github.com/jedisct1/was-not-wasm">Was (not Wasm)</a> is a hostile allocator for AssemblyScript that is written in Rust.</li> <li>Wasmer has <a href="https://medium.com/wasmer/running-webassembly-100x-faster-%EF%B8%8F-a8237e9a372d">improved their startup time by 100x</a>.</li> <li><a href="http://troubles.md/posts/microwasm/">WebAssembly Troubles part 4: Microwasm.</a> The culmination of a series of posts about issues the author has with WebAssembly, along with proposals for how to fix them.</li> <li><a href="https://twitter.com/HelloRenj/status/1100499645401366535">Generating snow with Rust and Wasm</a> <ul> <li><a href="https://zen-liskov-772f98.netlify.com/">Live demo</a></li> <li><a href="https://github.com/renjithgr/wasm-make-some-snow">Source</a></li> </ul> </li> </ul> <h2 id="updates-from-rustwasm">Updates from <a href="https://github.com/rustwasm"><code class="highlighter-rouge">rustwasm/*</code></a></h2> <h3 id="rfcs">RFCs</h3> <h4 id="new-rfcs">New RFCs</h4> <p>None.</p> <h4 id="final-comment-period-rfcs">Final Comment Period RFCs</h4> <ul> <li><a href="https://github.com/rustwasm/rfcs/pull/6">Add support for local JavaScript snippets in <code class="highlighter-rouge">wasm-bindgen</code></a></li> </ul> <h4 id="merged-rfcs">Merged RFCs</h4> <p>None.</p> <h3 id="working-group-meetings">Working Group Meetings</h3> <ul> <li><a href="https://www.youtube.com/watch?v=3YjN69U6ySE">Watch the recording of this week’s working group meeting on YouTube</a></li> <li><a href="https://github.com/rustwasm/team/issues/258">Come join us at next week’s working group meeting!</a></li> </ul> <h3 id="rustwasmrust-parcel-template"><code class="highlighter-rouge">rustwasm/rust-parcel-template</code></h3> <ul> <li>@tock203 <a href="https://github.com/rustwasm/rust-parcel-template/pull/22">fixed a <code class="highlighter-rouge">ReferenceError</code></a> in the template’s initialization code.</li> </ul> <h3 id="rustwasmtwiggy"><code class="highlighter-rouge">rustwasm/twiggy</code></h3> <ul> <li>@data-pup <a href="https://github.com/rustwasm/twiggy/pull/253">set up <code class="highlighter-rouge">rustfmt</code>-checking</a> for our continuous integration.</li> <li>@alexcrichton <a href="https://github.com/rustwasm/twiggy/pull/250">made Twiggy account for header and section size bytes</a> of a Wasm binary, so Twiggy’s output should sum to 100% now instead of just short of that.</li> <li>@philipc <a href="https://github.com/rustwasm/twiggy/pull/247">updated Twiggy to version 0.17.0 of <code class="highlighter-rouge">gimli</code></a>, the crate it uses to parse DWARF debugging information.</li> <li>@alexcrichton <a href="https://github.com/rustwasm/twiggy/pull/245">switched Twiggy over to using the <code class="highlighter-rouge">wasmparser</code> crate</a> to parse Wasm binaries, which gives more precise byte offset and size information, and is faster than the old Wasm parser.</li> <li>@data-pup <a href="https://github.com/rustwasm/twiggy/pull/244">added an unreachable items summary</a> to the <code class="highlighter-rouge">twiggy dominators</code> output, so that all top-level rows’ sizes will sum to 100%.</li> </ul> <h3 id="rustwasmwasm-bindgen"><code class="highlighter-rouge">rustwasm/wasm-bindgen</code></h3> <ul> <li>@tyleranton added support for <a href="https://github.com/rustwasm/wasm-bindgen/pull/1302">emitting doc comments</a> in the TypeScript interface definition files that <code class="highlighter-rouge">wasm-bindgen</code> creates.</li> <li>@LegNeato <a href="https://github.com/rustwasm/wasm-bindgen/pull/1298">fixed the <code class="highlighter-rouge">wasm-bindgen-test</code> headless browser test runner</a> on macOS High Sierra.</li> <li>@alexcrichton <a href="https://github.com/rustwasm/wasm-bindgen/pull/1285">updated the <code class="highlighter-rouge">wasm-bindgen</code> guide</a> and added a “Deployment” section.</li> <li>@alexcrichton <a href="https://github.com/rustwasm/wasm-bindgen/pull/1279">added support for the new <code class="highlighter-rouge">TextEncoder.prototype.encodeInto</code> method</a> to <code class="highlighter-rouge">wasm-bindgen</code>’s generated JS glue when passing strings between wasm and JS.</li> </ul> <h3 id="rustwasmwasm-pack"><code class="highlighter-rouge">rustwasm/wasm-pack</code></h3> <ul> <li>@ashleygwilliams <a href="https://github.com/rustwasm/wasm-pack/pull/556">removed unnecessary entries</a> from the <code class="highlighter-rouge">"files"</code> key in <code class="highlighter-rouge">wasm-pack</code>’s generated <code class="highlighter-rouge">package.json</code>.</li> <li>@ashleygwilliams <a href="https://github.com/rustwasm/wasm-pack/pull/550">fixed the [wasm-pack] installer on windows</a> when it is downloaded multiple times and ends up with a <code class="highlighter-rouge">(1)</code> suffix in its filename.</li> <li>@surma <a href="https://github.com/rustwasm/wasm-pack/pull/542">wrote some docs on the <code class="highlighter-rouge">wee_alloc</code> integration</a> for the <code class="highlighter-rouge">wasm-pack</code> template.</li> <li>@DebugSteven <a href="https://github.com/rustwasm/wasm-pack/pull/536">wrote a series of get-started-in-X-environment tutorials</a> for <code class="highlighter-rouge">wasm-pack</code>.</li> </ul> <h2 id="requests-for-contribution">Requests for Contribution</h2> <p><strong>Want to get involved in Rust and WebAssembly? <a href="https://github.com/rustwasm/team/blob/master/README.md#get-involved">Join the Rust and WebAssembly working group!</a></strong></p> <ul> <li><a href="https://github.com/issues?q=is%3Aopen+is%3Aissue+user%3Arustwasm+archived%3Afalse+label%3A%22good+first+issue%22">All issues labeled “good first issue” in the <code class="highlighter-rouge">rustwasm/*</code> repositories</a></li> <li><a href="https://github.com/issues?q=is%3Aopen+is%3Aissue+user%3Arustwasm+archived%3Afalse+label%3A%22help+wanted%22">All issues labeled “help wanted” in the <code class="highlighter-rouge">rustwasm/*</code> repositories</a></li> </ul> <h3 id="new-good-first-issues">New Good First Issues</h3> <ul> <li><a href="https://github.com/rustwasm/wasm-bindgen/issues/1284"><code class="highlighter-rouge">wasm-bindgen</code>: Add <code class="highlighter-rouge">#[wasm_bindgen(ignore)]</code> to ignore a <code class="highlighter-rouge">pub</code> field and not generate getters/setters for it</a></li> </ul>Hello and welcome to another issue of This Week in Rust and WebAssembly!This Week in Rust and WebAssembly 112019-02-21T00:00:00+00:002019-02-21T00:00:00+00:00https://rustwasm.github.io/2019/02/21/this-week-in-rust-and-wasm-011<p>Hello and welcome to another issue of <em>This Week in Rust and WebAssembly</em>!</p> <p><a href="https://rust-lang.org">Rust</a> is a systems language pursuing the trifecta: safety, concurrency, and speed.</p> <p><a href="http://webassembly.org">WebAssembly</a> is a stack-based virtual machine and instruction set. It is fast, safe, portable, and part of the open Web platform. By compiling to WebAssembly, we can run Rust code on the Web!</p> <p>This is a weekly summary of Rust and WebAssembly’s progress and community.</p> <p>Did we miss something? Tweet to us at <a href="https://twitter.com/rustwasm">@rustwasm</a> or <a href="https://github.com/rustwasm/rustwasm.github.io">send us a pull request</a>.</p> <p><strong>Want to get involved in Rust and WebAssembly? <a href="https://github.com/rustwasm/team/blob/master/README.md#get-involved">Join the Rust and WebAssembly working group!</a></strong></p> <!-- TODO: check recent r/rust and users.rust-lang.org posts for "wasm" and "webassembly": --> <h2 id="news-and-blog-posts-from-around-the-web">News and Blog Posts from Around the Web</h2> <p><em>Want to make sure something ends up on this list next time we publish an issue? <a href="https://github.com/rustwasm/team/issues/79">Leave a comment on this issue.</a></em></p> <ul> <li><a href="https://twitter.com/chinedufn/status/1098418821591957504">Parsing and rendering PSD files in the browser with Rust and WebAssembly</a></li> <li><a href="https://twitter.com/fitzgen/status/1097941877884473344">Programmatically generating Islamic stars</a> using the “Polygons in Contact” method with Rust-generated Wasm and Web GL <ul> <li><a href="https://johanneshoff.com/geotoy/">Live demo</a></li> <li><a href="https://github.com/fitzgen/geotoy">Source</a></li> </ul> </li> <li><a href="https://twitter.com/AsgerNyman/status/1096389338211016705">Dust is a renderer written in Rust that has a backend for Wasm and Web GL</a> <ul> <li><a href="https://asny.github.io/spider-web/index.html">Live demo</a></li> <li><a href="https://github.com/asny/Dust">Source</a></li> </ul> </li> </ul> <h2 id="updates-from-rustwasm">Updates from <a href="https://github.com/rustwasm"><code class="highlighter-rouge">rustwasm/*</code></a></h2> <h3 id="rfcs">RFCs</h3> <h4 id="new-rfcs">New RFCs</h4> <p>None.</p> <h4 id="merged-rfcs">Merged RFCs</h4> <p>None.</p> <h3 id="console_error_panic_hook"><code class="highlighter-rouge">console_error_panic_hook</code></h3> <ul> <li>@fitzgen <a href="https://github.com/rustwasm/console_error_panic_hook/pull/10">added error stacks</a> to the message we log when a panic occurs. This works around bugs in both Safari’s and Firefox’s developer tools consoles.</li> </ul> <h3 id="js-sys"><code class="highlighter-rouge">js-sys</code></h3> <ul> <li>@Pauan <a href="https://github.com/rustwasm/wasm-bindgen/pull/1225">added convenience getters to <code class="highlighter-rouge">js_sys::Reflect</code></a> for getting properties keyed by <code class="highlighter-rouge">u32</code> and <code class="highlighter-rouge">f64</code>.</li> </ul> <h3 id="twiggy">Twiggy🌱</h3> <ul> <li>@data-pup <a href="https://github.com/rustwasm/twiggy/pull/243">fixed some unused-result warnings</a> in Twiggy’s parser.</li> </ul> <h3 id="walrus"><code class="highlighter-rouge">walrus</code></h3> <ul> <li>@alexcrichton made <a href="https://github.com/rustwasm/walrus/pull/60">GC’ing unused functions, globals, etc an explicit pass</a> in <code class="highlighter-rouge">walrus</code>. It was previously performed implicitly as part of serializing a wasm module.</li> <li>@alexcrichton <a href="https://github.com/rustwasm/walrus/pull/50">implemented support for the reference types proposal</a> and <code class="highlighter-rouge">anyref</code> in <code class="highlighter-rouge">walrus</code>.</li> <li>@fitzgen <a href="https://github.com/rustwasm/walrus/pull/58">added the ability to explicitly delete</a> various wasm constructs (functions, tables, etc) from a wasm module, rather than just implicitly delete them by making them unused and then running a GC.</li> </ul> <h3 id="wasm-bindgen"><code class="highlighter-rouge">wasm-bindgen</code></h3> <ul> <li>@alexcrichton added support for <a href="https://github.com/rustwasm/wasm-bindgen/pull/1275"><code class="highlighter-rouge">Option&lt;MyRustStruct&gt;</code> in parameters and return positions</a>.</li> <li>@alexcrichton <a href="https://github.com/rustwasm/wasm-bindgen/pull/1002">added experimental support for using <code class="highlighter-rouge">anyref</code></a> in <code class="highlighter-rouge">wasm-bindgen</code>.</li> <li>@fitzgen <a href="https://github.com/rustwasm/wasm-bindgen/pull/1255">fixed a regression</a> where DWARF debug info custom sections were always being included in the generated Wasm, even when debug info was not enabled.</li> <li>@alexcrichton <a href="https://github.com/rustwasm/wasm-bindgen/pull/1256">added a flag</a> to control whether the producers custom section is included in the generated wasm binary or not.</li> <li>@ctjhoa <a href="https://github.com/rustwasm/wasm-bindgen/pull/1259">fixed some deprecation warnings</a> around the use of <code class="highlighter-rouge">ATOMICS_*_INIT</code> instead of <code class="highlighter-rouge">Atomic*::new</code>.</li> </ul> <h3 id="wasm-snip"><code class="highlighter-rouge">wasm-snip</code></h3> <ul> <li>@fitzgen ported <code class="highlighter-rouge">wasm-snip</code> over to <a href="https://github.com/rustwasm/wasm-snip/pull/21">using the <code class="highlighter-rouge">walrus</code> crate</a>. This also removes the need to <code class="highlighter-rouge">wasm-gc</code> again after running <code class="highlighter-rouge">wasm-snip</code>.</li> </ul> <h3 id="web-sys"><code class="highlighter-rouge">web-sys</code></h3> <ul> <li>@selaux <a href="https://github.com/rustwasm/wasm-bindgen/pull/1248">added a missing Web IDL attribute</a> to <code class="highlighter-rouge">HTMLMediaElement</code> so that <code class="highlighter-rouge">web-sys</code> correctly generates bindings to the <code class="highlighter-rouge">srcObject</code> property.</li> </ul> <h3 id="wee_alloc"><code class="highlighter-rouge">wee_alloc</code></h3> <ul> <li><a href="https://github.com/rustwasm/wee_alloc/blob/master/CHANGELOG.md#043"><strong>We released <code class="highlighter-rouge">wee_alloc</code> version 0.4.3! 🎉</strong></a> Among other things, this version will work on stable Rust as soon as 1.33 is released, which is scheduled for one week from today: 2019-02-28.</li> </ul> <h2 id="requests-for-contribution">Requests for Contribution</h2> <p><strong>Want to get involved in Rust and WebAssembly? <a href="https://github.com/rustwasm/team/blob/master/README.md#get-involved">Join the Rust and WebAssembly working group!</a></strong></p> <ul> <li><a href="https://github.com/issues?q=is%3Aopen+is%3Aissue+user%3Arustwasm+archived%3Afalse+label%3A%22good+first+issue%22">All issues labeled “good first issue” in the <code class="highlighter-rouge">rustwasm/*</code> repositories</a></li> <li><a href="https://github.com/issues?q=is%3Aopen+is%3Aissue+user%3Arustwasm+archived%3Afalse+label%3A%22help+wanted%22">All issues labeled “help wanted” in the <code class="highlighter-rouge">rustwasm/*</code> repositories</a></li> </ul> <h3 id="new-good-first-issues">New Good First Issues</h3> <ul> <li><a href="https://github.com/rustwasm/wasm-bindgen/issues/1270"><code class="highlighter-rouge">wasm-bindgen</code>: Handling <code class="highlighter-rouge">undefined</code> arguments</a></li> <li><a href="https://github.com/rustwasm/wasm-bindgen/issues/1276"><code class="highlighter-rouge">wasm-bindgen</code>: Add doc comments from Rust to generated TypeScript definitions</a></li> </ul>Hello and welcome to another issue of This Week in Rust and WebAssembly!This Week in Rust and WebAssembly 102019-02-13T00:00:00+00:002019-02-13T00:00:00+00:00https://rustwasm.github.io/2019/02/13/this-week-in-rust-and-wasm-010<p>Hello and welcome to another issue of <em>This Week in Rust and WebAssembly</em>!</p> <p><a href="https://rust-lang.org">Rust</a> is a systems language pursuing the trifecta: safety, concurrency, and speed.</p> <p><a href="http://webassembly.org">WebAssembly</a> is a stack-based virtual machine and instruction set. It is fast, safe, portable, and part of the open Web platform. By compiling to WebAssembly, we can run Rust code on the Web!</p> <p>This is a weekly summary of Rust and WebAssembly’s progress and community.</p> <p>Did we miss something? Tweet to us at <a href="https://twitter.com/rustwasm">@rustwasm</a> or <a href="https://github.com/rustwasm/rustwasm.github.io">send us a pull request</a>.</p> <h2 id="news-and-blog-posts-from-around-the-web">News and Blog Posts from Around the Web</h2> <p><em>Want to make sure something ends up on this list next time we publish an issue? <a href="https://github.com/rustwasm/team/issues/79">Leave a comment on this issue.</a></em></p> <ul> <li> <p><a href="https://rustwasm.github.io/2018/12/06/reflecting-on-rust-and-wasm-in-2018.html"><strong>Reflecting on Rust and WebAssembly in 2018</strong></a></p> </li> <li> <p><a href="http://fitzgeraldnick.com/2018/12/02/wasm-bindgen-how-does-it-work.html"><code class="highlighter-rouge">wasm-bindgen</code> — how does it work?!</a></p> </li> <li> <p><a href="https://www.fastly.com/blog/edge-programming-rust-web-assembly">Edge programming with Rust and WebAssembly with Terrarium</a></p> </li> <li> <p><a href="https://medium.com/wasmer/executing-webassembly-in-your-rust-application-d5cd32e8ce46">Embedding WebAssembly in your Rust Application with wasmer.io</a></p> </li> <li> <p><a href="https://github.com/iamcodemaker/console_log">The <code class="highlighter-rouge">console_log</code> crate</a> is a backend for <a href="https://crates.io/crates/log">the <code class="highlighter-rouge">log</code> facade</a> that pipes logged messages to the browser’s console.</p> </li> <li> <p><a href="https://ozkriff.itch.io/zemeroth">Zemeroth</a> is a turn-based hexagonal tactical game written in Rust and WebAssembly.</p> </li> <li> <p><a href="https://github.com/richardanaya/virtual-dom-rs-counter">An example implementation of react/redux style UI development in Rust with <code class="highlighter-rouge">percy</code></a></p> </li> <li> <p><a href="https://github.com/David-OConnor/seed">Seed</a> is a new Wasm framework for Web apps.</p> </li> <li> <p><a href="https://github.com/sendilkumarn/generator-wasm-app"><code class="highlighter-rouge">sendilkumarn/generator-wasm-app</code></a> is a a Wasm app generator for <a href="https://yeoman.io/">Yeoman</a>.</p> </li> <li> <p><a href="https://github.com/edvorg/rustmith"><code class="highlighter-rouge">edvorg/rustsmith</code></a> is a Rocksmith clone for the Web platform built with Rust and WebAssembly.</p> </li> </ul> <h3 id="rustwasm2019-posts"><code class="highlighter-rouge">#RustWasm2019</code> Posts</h3> <ul> <li> <p><a href="https://blog.ryanlevick.com/posts/rust-wasm-2019/">Rust WebAssembly 2019</a> by Ryan Levick</p> </li> <li> <p><a href="https://www.reddit.com/r/rust/comments/aac8zk/my_rust_2019_dream_dominate_the_web/">My Rust 2019 Dream: Dominate the Web</a> by richardanaya</p> </li> <li> <p><a href="https://blog.yoshuawuyts.com/wasm-2019/">Wasm 2019</a> by Yoshua Wuyts</p> </li> <li> <p><a href="http://fitzgeraldnick.com/2018/12/14/rust-and-webassembly-in-2019.html">Rust and WebAssembly in 2019</a> by Nick Fitzgerald</p> </li> <li> <p><a href="https://medium.com/wasmer/non-web-embeddings-for-rust-wasm-2019-7b290e94f81d">Non-Web Embeddings for Rust Wasm 2019</a> by Brandon Fish and wasmer.io</p> </li> </ul> <h2 id="wasm-at-the-2019-rust-all-hands">Wasm at the 2019 Rust All Hands</h2> <p>The 2019 Rust All Hands meetup was in Berlin on February 4<sup>th</sup> through 8<sup>th</sup>. @ag_dubs, @alexcrichton, @fitzgen, and @yoshuawuyts from the Rust and WebAssembly working group all made it out to discuss some Wasm-related topics and plan for 2019.</p> <p>We talked about:</p> <ul> <li> <p><a href="https://gist.github.com/fitzgen/23a62ebbd67574b9f6f72e5ac8eaeb67#file-road-to-wasm-pack-1-0-md">The road to <code class="highlighter-rouge">wasm-pack</code> 1.0.</a> This meeting was about trying to pin down what we want to ship as part of a <code class="highlighter-rouge">wasm-pack</code> 1.0 release, as well as crystallize <code class="highlighter-rouge">wasm-pack</code>’s ideal UX.</p> </li> <li> <p><a href="https://gist.github.com/fitzgen/23a62ebbd67574b9f6f72e5ac8eaeb67#file-modular-toolkit-md">A modular toolkit for Wasm.</a> There’s been a lot of talk in <code class="highlighter-rouge">#RustWasm2019</code> posts and the 2019 roadmap RFC about building a modular toolkit for Wasm apps and libraries. This meeting was trying to dig a bit more into the details of what that entails. And naming, of course.</p> </li> <li> <p><a href="https://gist.github.com/fitzgen/23a62ebbd67574b9f6f72e5ac8eaeb67#file-cargo-build-hooks-for-wasm-md"><code class="highlighter-rouge">cargo</code> build tasks, hooks, and/or <code class="highlighter-rouge">post-build.rs</code> for Wasm.</a> Long-term (likely on the timeline of a couple years) we would like the experience of building Rust and Wasm projects to be <em>exactly</em> the same as building normal Rust projects: just <code class="highlighter-rouge">cargo build</code> and that’s it. But there is a bunch of stuff that needs to happen for Wasm after <code class="highlighter-rouge">rustc</code> emits a Wasm binary, such as generate JS bindings or run <code class="highlighter-rouge">wasm-opt</code>. This meeting was about how to add some sort of generic build hooks to <code class="highlighter-rouge">cargo</code> and turn <code class="highlighter-rouge">wasm-pack</code> into an implementation of those generic hooks specifically targeted for Wasm development.</p> </li> <li> <p><a href="https://gist.github.com/fitzgen/23a62ebbd67574b9f6f72e5ac8eaeb67#file-wasm-multithreading-and-rayon-md">Multithreading Wasm and <code class="highlighter-rouge">rayon</code>.</a> This meeting was about how we take our experimental Wasm multithreading support and turn it into a reliable library that can serve as the foundation for multithreading on the Web. @CUViper from the <code class="highlighter-rouge">rayon</code> team also joined, and we made a plan for how to get <code class="highlighter-rouge">rayon</code> working in Wasm.</p> </li> </ul> <h2 id="updates-from-rustwasm">Updates from <a href="https://github.com/rustwasm"><code class="highlighter-rouge">rustwasm/*</code></a></h2> <h3 id="rfcs">RFCs</h3> <h4 id="new-rfcs">New RFCs</h4> <ul> <li> <p><a href="https://github.com/rustwasm/rfcs/pull/7"><strong>2019 Roadmap</strong></a> — this is your chance to help shape our goals for the year!</p> </li> <li> <p><a href="https://github.com/rustwasm/rfcs/pull/6">Add support for local JS snippets in <code class="highlighter-rouge">wasm-bindgen</code></a></p> </li> </ul> <h4 id="merged-rfcs">Merged RFCs</h4> <p>None.</p> <h3 id="book">Book</h3> <ul> <li>@DebugSteven <a href="https://github.com/rustwasm/book/pull/137">wrote a testing section</a> for the Game of Life tutorial!</li> </ul> <h3 id="twiggy">Twiggy🌱</h3> <ul> <li> <p><a href="https://github.com/rustwasm/twiggy/blob/master/CHANGELOG.md#040"><strong>We released Twiggy🌱 0.4.0! 🎉</strong></a></p> </li> <li> <p>@brson fixed a bug where we would <a href="https://github.com/rustwasm/twiggy/pull/232">attempt to demangle things that were not C++</a> symbols as if they were C++ symbols.</p> </li> </ul> <h3 id="walrus"><code class="highlighter-rouge">walrus</code></h3> <ul> <li> <p><a href="https://github.com/rustwasm/walrus"><code class="highlighter-rouge">walrus</code> is a new library crate for writing Wasm-to-Wasm transformations.</a> It will eventually (but doesn’t yet) preserve DWARF debug info for the Wasm across your transformations.</p> </li> <li> <p>@alexcrichton got <code class="highlighter-rouge">walrus</code> <a href="https://github.com/rustwasm/walrus/pull/24">round-tripping all the Wasm spec tests</a> correctly.</p> </li> <li> <p>@fitzgen <a href="https://github.com/rustwasm/walrus/pull/45">wrote a simple Wasm fuzzer</a>, immediately found a bug, and whipped up a fix.</p> </li> <li> <p>@alexcrichton refactored instruction parsing to <a href="https://github.com/rustwasm/walrus/pull/48">avoid recursion</a>. This means that we don’t blow the stack in debug builds or when given malicious input.</p> </li> <li> <p>We just released <code class="highlighter-rouge">walrus</code> 0.1.0 on crates.io — expect more exciting things from <code class="highlighter-rouge">walrus</code> in the future :)</p> </li> </ul> <h3 id="wasm-bindgen"><code class="highlighter-rouge">wasm-bindgen</code></h3> <ul> <li> <p><a href="https://github.com/rustwasm/wasm-bindgen/blob/master/CHANGELOG.md#0236"><strong>We released <code class="highlighter-rouge">wasm-bindgen</code> 0.2.29 through 0.2.36! 🎉</strong></a></p> </li> <li> <p>@derekdreery <a href="https://github.com/rustwasm/wasm-bindgen/pull/1161">improved the <code class="highlighter-rouge">std::fmt::Debug</code> output for <code class="highlighter-rouge">JsValue</code></a> so that it includes object properties and their values, instead of just <code class="highlighter-rouge">[object Object]</code>.</p> </li> <li> <p>@fitzgen made the <code class="highlighter-rouge">wasm-bindgen-test</code> testing infrastructure <a href="https://github.com/rustwasm/wasm-bindgen/pull/1184">capture more <code class="highlighter-rouge">console</code> logging methods’ (<code class="highlighter-rouge">warn</code>, <code class="highlighter-rouge">info</code>, etc) output</a> for displaying in <code class="highlighter-rouge">stdout</code>.</p> </li> <li> <p>@T5uku5hi <a href="https://github.com/rustwasm/wasm-bindgen/pull/1207">added <code class="highlighter-rouge">#[allow(clippy::all)]</code> to <code class="highlighter-rouge">wasm-bindgen</code>’s macro-generated code,</a> so that running clippy on crates that use <code class="highlighter-rouge">wasm-bindgen</code> isn’t so noisy.</p> </li> <li> <p>@alexcrichton added support for <a href="https://github.com/rustwasm/wasm-bindgen/pull/1214">passing <code class="highlighter-rouge">Option&lt;MyEnum&gt;</code> back and forth</a> between Wasm and JS if <code class="highlighter-rouge">MyEnum</code> has the <code class="highlighter-rouge">#[wasm_bindgen]</code> attribute.</p> </li> <li> <p>@fitzgen <a href="https://github.com/rustwasm/wasm-bindgen/pull/1219">added the <code class="highlighter-rouge">UnwrapThrowExt</code> trait</a> to <code class="highlighter-rouge">wasm-bindgen</code>’s prelude. This extension trait adds <code class="highlighter-rouge">unwrap_throw</code> and <code class="highlighter-rouge">expect_throw</code> methods to <code class="highlighter-rouge">Option&lt;T&gt;</code> and <code class="highlighter-rouge">Result&lt;T, E&gt;</code> that have the same behavior as regular <code class="highlighter-rouge">unwrap</code> and <code class="highlighter-rouge">expect</code> except they throw a JS error on failure instead of panicking. This is morally the same, but ends up avoiding the <code class="highlighter-rouge">std::panicking</code> and <code class="highlighter-rouge">std::fmt</code> infrastructure, resulting in smaller code sizes.</p> </li> <li> <p>@alexcrichton <a href="https://github.com/rustwasm/wasm-bindgen/pull/1237">migrated <code class="highlighter-rouge">wasm-bindgen</code>’s post-<code class="highlighter-rouge">rustc</code> Wasm transformations</a> to the new <code class="highlighter-rouge">walrus</code> crate! This paves the way for maintaining DWARF debug info through <code class="highlighter-rouge">wasm-bindgen</code>.</p> </li> <li> <p>@fitzgen made the <code class="highlighter-rouge">wasm-bindgen-test</code> runtime capture logged messages in tests <a href="https://github.com/rustwasm/wasm-bindgen/pull/1233">via <code class="highlighter-rouge">textContent</code> instead of <code class="highlighter-rouge">innerHTML</code></a>, avoiding issues when logging HTML strings ;)</p> </li> </ul> <h3 id="wasm-pack"><code class="highlighter-rouge">wasm-pack</code></h3> <ul> <li> <p><a href="https://github.com/rustwasm/wasm-pack/blob/master/CHANGELOG.md#-060"><strong>We released <code class="highlighter-rouge">wasm-pack</code> 0.6.0! 🎉</strong></a></p> </li> <li> <p>@drager implemented <a href="https://github.com/rustwasm/wasm-pack/pull/446">support for typo detection</a> in <code class="highlighter-rouge">wasm-pack</code>’s <code class="highlighter-rouge">Cargo.toml</code> section.</p> </li> <li> <p>@torkve added support for <a href="https://github.com/rustwasm/wasm-pack/pull/461">passing arbitrary extra CLI arguments through <code class="highlighter-rouge">wasm-pack build</code></a> and into <code class="highlighter-rouge">cargo build</code>. For example, to build with all cargo features enabled: <code class="highlighter-rouge">wasm-pack build -- --all-features</code>.</p> </li> <li> <p>This inspired @chinedufn to add support for <a href="https://github.com/rustwasm/wasm-pack/pull/530">passing arbitrary extra CLI arguments through <code class="highlighter-rouge">wasm-pack test</code></a> and into <code class="highlighter-rouge">cargo test</code>!</p> </li> <li> <p>@fitzgen fixed a bug where <a href="https://github.com/rustwasm/wasm-pack/pull/521">the output of <code class="highlighter-rouge">wasm-pack test</code> was printed twice</a>.</p> </li> <li> <p>@rhysd added support for <a href="https://github.com/rustwasm/wasm-pack/pull/531">emitting the “homepage” field</a> in our generated <code class="highlighter-rouge">package.json</code> if it is present in the crate’s <code class="highlighter-rouge">Cargo.toml</code>.</p> </li> <li> <p>@jscheffner <a href="https://github.com/rustwasm/wasm-pack/pull/537">fixed <code class="highlighter-rouge">wasm-pack</code>’s fetching of <code class="highlighter-rouge">chromedriver</code> binaries</a> for headless browser testing on Windows.</p> </li> </ul> <h2 id="requests-for-contribution">Requests for Contribution</h2> <p><em>Want to get involved in Rust and WebAssembly? <a href="https://github.com/rustwasm/team/blob/master/README.md#get-involved">Join the Rust and WebAssembly working group!</a></em></p> <ul> <li> <p><a href="https://github.com/issues?q=is%3Aopen+is%3Aissue+user%3Arustwasm+archived%3Afalse+label%3A%22good+first+issue%22">All issues labeled “good first issue” in the <code class="highlighter-rouge">rustwasm/*</code> repositories</a></p> </li> <li> <p><a href="https://github.com/issues?q=is%3Aopen+is%3Aissue+user%3Arustwasm+archived%3Afalse+label%3A%22help+wanted%22">All issues labeled “help wanted” in the <code class="highlighter-rouge">rustwasm/*</code> repositories</a></p> </li> </ul> <h3 id="new-help-wanted-issues">New “Help Wanted” Issues</h3> <ul> <li> <p><a href="https://github.com/rustwasm/wasm-pack/issues/533"><code class="highlighter-rouge">wasm-pack</code> — docs: add documentation for working with wasm-pack outside of template</a></p> </li> <li> <p><a href="https://github.com/rustwasm/wasm-pack/issues/470"><code class="highlighter-rouge">wasm-pack</code> — installer: do not attempt to install to /usr/bin</a></p> </li> </ul>Hello and welcome to another issue of This Week in Rust and WebAssembly!Reflecting on Rust and WebAssembly in 20182018-12-06T00:00:00+00:002018-12-06T00:00:00+00:00https://rustwasm.github.io/2018/12/06/reflecting-on-rust-and-wasm-in-2018<p><a href="https://blog.rust-lang.org/2018/12/06/Rust-1.31-and-rust-2018.html"><strong>🎉 The 2018 edition of Rust has officially shipped, and the initial Rust and WebAssembly development story along with it! 🎉</strong></a></p> <p>To see how far we’ve come, let’s reflect on the Rust and WebAssembly story a year ago: <code class="highlighter-rouge">rustc</code> could emit WebAssembly binaries for you, but that was about it. As far as communication with JavaScript went, you had to work with raw wasm imports and exports yourself. That meant you could only pass 32- and 64-bit integers and floats back and forth. No Rust structs, JavaScript objects, strings, or slices could be passed back forth. And distributing your library’s <code class="highlighter-rouge">.wasm</code> so that other downstream projects could depend on it? Good luck.</p> <p>While it was <a href="https://mgattozzi.com/rust-wasm/">clear there was huge potential for Rust and WebAssembly</a>, no one was sure what exactly that meant. So when the Rust and WebAssembly domain working group formed, we rallied around making this shared vision into a reality:</p> <blockquote> <h4 id="compiling-rust-to-webassembly-should-be-the-best-choice-for-fast-reliable-code-for-the-web">Compiling Rust to WebAssembly should be the best choice for fast, reliable code for the Web.</h4> </blockquote> <p>As our ideas evolved, we distilled another core value:</p> <blockquote> <h4 id="rust-and-webassembly-is-here-to-augment-your-javascript-not-replace-it">Rust and WebAssembly is here to <em>augment</em> your JavaScript, not replace it.</h4> </blockquote> <p>The same way that Rust integrates with C libraries and calling conventions on native targets, it should play nice with JavaScript and HTML5 APIs on the Web. You should <em>not</em> have to rewrite your whole Web application or JavaScript library. We cannot realize our vision for Rust and wasm if it means you have to start over from scratch; it wouldn’t be practical.</p> <p>Given these shared values and vision, we set out goals for what we wanted the Rust and WebAssembly ecosystem, toolchain, and workflow to look like by the time Rust 2018 shipped.</p> <h3 id="goal--zero-cost-javascript-interoperation">Goal: ☑ Zero-Cost JavaScript Interoperation</h3> <p>Rust enables fast <em>and</em> expressive code by leveraging zero-cost abstractions. We wanted to apply this principle to our whole JS interop infrastructure. Yes, you can write your own boilerplate to pass DOM nodes to Rust-generated wasm, but you shouldn’t have to, and the provided infrastructure should be as fast as if you <em>did</em> hand-code it. If you call IndexedDB APIs, that shouldn’t bloat your <code class="highlighter-rouge">.wasm</code> binary with unused bindings to Web GL functions.</p> <p><a href="https://github.com/rustwasm/wasm-bindgen">We created <code class="highlighter-rouge">wasm-bindgen</code> as the foundation for zero-cost JavaScript interoperation.</a> <code class="highlighter-rouge">wasm-bindgen</code> facillitates communication between JavaScript and WebAssembly, and generates glue code that you would otherwise have to write yourself. On top of <code class="highlighter-rouge">wasm-bindgen</code>, <a href="https://rustwasm.github.io/2018/09/26/announcing-web-sys.html">we built <code class="highlighter-rouge">js-sys</code> (raw bindings to ECMAScript APIs) and <code class="highlighter-rouge">web-sys</code> (raw bindings to Web APIs)</a>.</p> <p>Using the <code class="highlighter-rouge">wasm-bindgen</code> ecosystem, we can easily and performantly</p> <ul> <li>export rich APIs from our Rust-generated wasm libraries, so they are callable from JavaScript, and</li> <li>import JavaScript and Web APIs into our Rust-generated wasm.</li> </ul> <p>All in a zero-cost manner.</p> <p>Additionally, <code class="highlighter-rouge">wasm-bindgen</code> is forward-compatible with the <a href="https://github.com/WebAssembly/webidl-bindings/blob/master/proposals/webidl-bindings/Explainer.md">WebAssembly host bindings proposal</a>. Host bindings will remove the tiny, generated JavaScript shim functions that sit between our wasm functions and DOM methods. Eventually, host bindings promises to unlock even-faster-than-JavaScript DOM access since calls can be statically validated once rather than dynamically checked every time.</p> <h3 id="goal--distributing-rust-generated-wasm-as-an-npm-library">Goal: ☑ Distributing Rust-Generated Wasm as an NPM Library</h3> <p>Superb integration isn’t only about exporting and importing functionality between Rust-generated WebAssembly and JavaScript. It is also fitting into the JavaScript’s distribution mechanisms, and a big chunk of that story is <a href="https://www.npmjs.com/">NPM</a>.</p> <p>We <a href="https://github.com/rustwasm/wasm-pack">built <code class="highlighter-rouge">wasm-pack</code></a> to make it easy to create and publish NPM packages from your Rust and WebAssembly code. There didn’t used to be any story whatsoever for sharing Rust-generated wasm modules. Now, all it takes is:</p> <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>wasm-pack publish </code></pre></div></div> <h3 id="goal--get-developers-productive-fast">Goal: ☑ Get Developers Productive Fast</h3> <p>We wrote <a href="https://rustwasm.github.io/book/">a Rust and WebAssembly book</a> that teaches you all the ins and outs of WebAssembly development with Rust. It features <a href="https://rustwasm.github.io/book/game-of-life/introduction.html">a tutorial where you build an implementation of Conway’s Game of Life</a>, and then you learn to write tests for headless browsers, debug wasm code when things go wrong, and how to diagnose slow code paths and then speed them up.</p> <p>We realized that there are a bunch of “post-build” tools you want to run after <code class="highlighter-rouge">cargo</code> and <code class="highlighter-rouge">rustc</code> emit the initial <code class="highlighter-rouge">.wasm</code> binary. For usability and developer productivity, we expanded <code class="highlighter-rouge">wasm-pack</code>’s role from creating and publishing NPM packages to orchestrating all of these tasks. <code class="highlighter-rouge">wasm-pack</code> will manage your <code class="highlighter-rouge">wasm-bindgen</code> CLI binaries and install browsers’ WebDriver clients for you automatically.</p> <p>For example, want to run tests in a headless Firefox browser? Just run</p> <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>wasm-pack test --headless --firefox </code></pre></div></div> <p>No need to pull your hair out trying to install and configure anything!</p> <p>Finally, we recognized that getting your Rust and WebAssembly project set up initially involves a bit of boilerplate and configuration that new users aren’t prepared for and experienced users don’t want to waste time on. So we created a variety of project templates for different use cases, so you can hit the ground running:</p> <ul> <li><a href="https://github.com/rustwasm/wasm-pack-template"><code class="highlighter-rouge">wasm-pack-template</code></a> for creating NPM libraries with Rust and Wasm.</li> <li><a href="https://github.com/rustwasm/create-wasm-app"><code class="highlighter-rouge">create-wasm-app</code></a> for creating Web applications built on top of Rust-generated wasm NPM libraries.</li> <li><a href="https://github.com/rustwasm/rust-webpack-template"><code class="highlighter-rouge">rust-webpack-template</code></a> for creating whole Web applications with Rust, WebAssembly, and the Webpack bundler.</li> <li><a href="https://github.com/rustwasm/rust-parcel-template"><code class="highlighter-rouge">rust-parcel-template</code></a> for creating whole Web applications with Rust, WebAssembly, and the Parcel bundler.</li> </ul> <h3 id="goal--rust-generated-wasm-should-be-testable-and-debuggable">Goal: ☑ Rust-Generated Wasm Should be Testable and Debuggable</h3> <p>We recognized that testing and debugging infrastructure are table stakes for creating reliable code and developer productivity.</p> <p>By default, wasm can’t log any panics or errors because it doesn’t have any “syscall” or I/O functionality. You have to add imports for that sort of thing yourself, and then instantiate the module with the appropriate functions. To remedy this problem, and to ensure that panics are always debuggable, we created <a href="https://github.com/rustwasm/console_error_panic_hook">the <code class="highlighter-rouge">console_error_panic_hook</code> crate</a>, which redirects panic messages into the browser’s devtools console.</p> <p>While you can always run normal <code class="highlighter-rouge">#[test]</code>s on the native target for portable, platform-agnostic code, that isn’t sufficient for testing your library’s interaction with the DOM, asynchronous JavaScript promises, or event handlers. So we created <a href="https://rustwasm.github.io/wasm-bindgen/wasm-bindgen-test/index.html">the <code class="highlighter-rouge">wasm-bindgen-test</code> infrastructure</a>, and made installing and configuring the necessary binaries for headless browser and Node.js testing a breeze with <code class="highlighter-rouge">wasm-pack test</code>.</p> <p>We also had experienced that diagnosing where code size was coming from could be hard with WebAssembly. We wanted to know things like which function was calling another function, and causing it to be included in the <code class="highlighter-rouge">.wasm</code> binary, so we created <a href="https://github.com/rustwasm/twiggy">the Twiggy🌱 code size profiler for WebAssembly</a>.</p> <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code> Shallow Bytes │ Shallow % │ Retaining Paths ───────────────┼───────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 152 ┊ 5.40% ┊ wee_alloc::alloc_with_refill::hb32c1bbce9ebda8e ┊ ┊ ⬑ func[2] ┊ ┊ ⬑ &lt;wee_alloc::size_classes::SizeClassAllocPolicy&lt;'a&gt; as wee_alloc::AllocPolicy&gt;::new_cell_for_free_list::h3987e3054b8224e6 ┊ ┊ ⬑ func[5] ┊ ┊ ⬑ elem[0] ┊ ┊ ⬑ hello ┊ ┊ ⬑ func[8] ┊ ┊ ⬑ export "hello" </code></pre></div></div> <h2 id="rustwasm2019">#RustWasm2019</h2> <p>All of our goals have been focused on things we could deliver in tandem with the 2018 edition. But now that the 2018 edition has shipped, it is time to think about what we want to achieve in 2019 and beyond.</p> <p><strong>This is where you come in!</strong></p> <p>Following in the larger Rust project’s <a href="https://blog.rust-lang.org/2018/12/06/call-for-rust-2019-roadmap-blogposts.html">tradition</a>, we’re asking the community to write blog posts reflecting on Rust and WebAssembly in 2018 and proposing goals and directions for Rust and WebAssembly in 2019. We’ll read everything, and then propose an <a href="https://github.com/rustwasm/rfcs">RFC</a> for the Rust and WebAssembly domain working group’s roadmap in 2019.</p> <p>Write down your thoughts on whatever your writing platform of choice is. It could be:</p> <ul> <li>Your personal or company blog</li> <li>A GitHub gist</li> <li>A Medium post</li> <li>Any other platform you prefer</li> </ul> <p>We’re looking for posts on many different topics:</p> <ul> <li>Ideas for community programs</li> <li>Tooling enhancements</li> <li>Ecosystem and library needs</li> <li>Documentation improvements</li> <li>Anything else related to Rust and Wasm!</li> </ul> <p>Tweet your write up with <a href="https://twitter.com/search?q=%23RustWasm2019">the <code class="highlighter-rouge">#RustWasm2019</code> hashtag</a> or drop a link on <a href="https://github.com/rustwasm/team/issues/241">this github issue</a>. We’ll aggregate everything everyone has written in another big post on this blog. Then, the core Rust and WebAssembly working group team will read over all of them and write up an RFC for the working group’s 2019 roadmap! This RFC will follow our normal <a href="https://rustwasm.github.io/rfcs/001-the-rfc-process.html">RFC process</a> and everyone will have a chance to discuss it, improve it, and help polish it.</p> <h2 id="preliminary-timeline">Preliminary Timeline</h2> <ul> <li><strong>Now through January 15<sup>th</sup>:</strong> Share your <code class="highlighter-rouge">#RustWasm2019</code> post, read posts by others, discuss them, bounce ideas back and forth.</li> <li><strong>End of January:</strong> We’ll formally propose the 2019 roadmap RFC, and then work it through the RFC process together as a community.</li> <li><strong>End of February:</strong> We’re aiming for having consensus on the 2019 roadmap and merging the RFC before the end of February.</li> </ul> <h2 id="thank-you-for-a-wonderful-2018-">Thank You for a Wonderful 2018! 💖</h2> <p>Thanks to everyone who contributed to Rust and WebAssembly in 2018! (Apologies if we missed anyone in this list!)</p> <ul> <li>0xazure</li> <li>Aaron Turon</li> <li>Aditya Arora</li> <li>Aidan Hobson Sayers</li> <li>Aleksey Kladov</li> <li>Alex Crichton</li> <li>Alex Macleod</li> <li>Alexander Kryvomaz</li> <li>Alfie John</li> <li>Anders Pitman</li> <li>Andrew Champion</li> <li>Andrew Chin</li> <li>Andy Bell</li> <li>Anna Bogus</li> <li>Anton Danilkin</li> <li>Ashley Williams</li> <li>Ben Merritt</li> <li>Benjamin Kampmann</li> <li>Blixt</li> <li>Bradlee Speice</li> <li>Cameron Taggart</li> <li>Camille TJHOA</li> <li>Chinedu Francis Nwafili</li> <li>Chris Goller</li> <li>Chris Kolodin</li> <li>Christian Bourjau</li> <li>Christopher Lane Hinson</li> <li>Cldfire</li> <li>Corbin Uselton</li> <li>Corey Farwell</li> <li>Craig Disselkoen</li> <li>Dan Fockler</li> <li>Dan Reeves</li> <li>Daniel Gollahon</li> <li>Daniele Esposti</li> <li>Danielle Pham</li> <li>Darren Tsung</li> <li>David Flemström</li> <li>David McNeil</li> <li>David O’Connor</li> <li>DebugSteven</li> <li>Dimitrii Nemkov</li> <li>Dmitry Kashitsyn</li> <li>Eduard Kyvenko</li> <li>Erick Tryzelaar</li> <li>Erika Kloss</li> <li>Evan Shaw</li> <li>Felix Schütt</li> <li>Florian Gilcher</li> <li>Frank Hassanabad</li> <li>Frazer McLean</li> <li>Gergely Nagy</li> <li>Guy Waldman</li> <li>Hendrik Sollich</li> <li>Henrik Sjööh</li> <li>Herman J. Radtke III</li> <li>Hidehito Yabuuchi</li> <li>Ian Duke</li> <li>Ian McIntyre</li> <li>Ingvar Stepanyan</li> <li>Ioannis Valasakis</li> <li>Ivan Enderlin</li> <li>J. Ryan Stinnett</li> <li>Jamen Marz</li> <li>Jamie Kyle</li> <li>Jan Willem Henckel</li> <li>Jan-Erik Rediger</li> <li>Jannik Keye</li> <li>Jason Davies</li> <li>Jason Wohlgemuth</li> <li>Jesper Håkansson</li> <li>Jim Blandy</li> <li>Joel Gallant</li> <li>Johann Hofmann</li> <li>Johannes Henninger</li> <li>John Lewis</li> <li>Jonas Trollvik</li> <li>Jonathan Kingston</li> <li>Jonathan Sundqvist</li> <li>Josh Triplett</li> <li>Joshua Liebow-Feeser</li> <li>Joshua Sheard</li> <li>Josmar Dias</li> <li>João Lucas Lucchetta</li> <li>Julius Rakow</li> <li>Junjie Huang</li> <li>Katharina Fey</li> <li>Kevin Hoffman</li> <li>Kirill Bulatov</li> <li>Kyle Lin</li> <li>Lachezar Lechev</li> <li>Laurentiu Nicola</li> <li>Liigo Zhuang</li> <li>LongYinan</li> <li>Luke Wagner</li> <li>Mackenzie Clark</li> <li>Mackiovello</li> <li>Manas Karekar</li> <li>Marcin Baraniecki</li> <li>Mario Reder</li> <li>Mark Andrus Roberts</li> <li>Mark Hintz</li> <li>Markus Stange</li> <li>Mason Stallmo</li> <li>Matias Insaurralde</li> <li>Matt Harrison</li> <li>Matt Howell</li> <li>Matt Kraai</li> <li>Matt Long</li> <li>MaxD / vj userZero</li> <li>MaxXor</li> <li>Michael Gattozzi</li> <li>Michael Gerhaeuser</li> <li>Michael Hoffmann</li> <li>Mirclus</li> <li>Nathan Froyd</li> <li>Nick Fitzgerald</li> <li>Nik Graf</li> <li>Nikolay Volf</li> <li>Noah Lemen</li> <li>Noumir Poutipou</li> <li>OJ Kwon</li> <li>Pascal Brandt</li> <li>Pascal Hertleif</li> <li>Pat Hickey</li> <li>Peter Trotman</li> <li>R. Andrew Ohana</li> <li>Rahul Sharma</li> <li>Ralph Giles</li> <li>Renée Kooi</li> <li>Ricardo Ambrogi</li> <li>Richard Dodd (dodj)</li> <li>Robert Masen</li> <li>Roberto Huertas</li> <li>Rongjian Zhang</li> <li>Ruben Schmidmeister</li> <li>Ryan Levick</li> <li>Sallar Kaboli</li> <li>Santiago Pastorino</li> <li>Satoshi Amemiya</li> <li>Scott Johnson</li> <li>Sebastian Köln</li> <li>Sendil Kumar N</li> <li>Sergey Pepyakin</li> <li>Sharad Chand</li> <li>Sonny Scroggin</li> <li>Sophie Alpert</li> <li>Spencer Wilson</li> <li>Stefan Novak</li> <li>Stefan Zimmermann</li> <li>Stephan Renatus</li> <li>Stephan Wolski</li> <li>Steve Klabnik</li> <li>Sven Sauleau</li> <li>T. Nagasawa</li> <li>Tao He</li> <li>Ted Mielczarek</li> <li>Theemathas Chirananthavat</li> <li>Thiago Pontes</li> <li>Thomas Eizinger</li> <li>Tim Ryan</li> <li>Tobias Bieniek</li> <li>Tomohide Takao</li> <li>Tomáš Hübelbauer</li> <li>Tyler Laing</li> <li>Tyler Wilcock</li> <li>William Lundstedt</li> <li>YUyz</li> <li>Yoshua Wuyts</li> <li>Yury Delendik</li> <li>Yuval Kohavi</li> <li>Zachary Pierce</li> <li>Zack Pierce</li> <li>afdw</li> <li>alkahest</li> <li>andy-bell</li> <li>arjunyel</li> <li>ashley williams</li> <li>belfz</li> <li>bokuweb</li> <li>bspeice</li> <li>csmoe</li> <li>data-pup</li> <li>dependabot[bot]</li> <li>frankhassanbad</li> <li>gaurikholkar</li> <li>gnzlbg</li> <li>huangjj27</li> <li>janczer</li> <li>johnthagen</li> <li>kohensu</li> <li>konstin</li> <li>kryptan</li> <li>kzvi</li> <li>limira</li> <li>na-g</li> <li>pup</li> <li>robert masen</li> <li>robertdurst</li> <li>sarahmeyer</li> <li>sepiropht</li> <li>sigmaSd</li> <li>soryrawyer</li> <li>teovoinea</li> <li>toversus</li> <li>twilco</li> <li>xeqlol</li> </ul>🎉 The 2018 edition of Rust has officially shipped, and the initial Rust and WebAssembly development story along with it! 🎉This Week in Rust and WebAssembly 0092018-11-28T00:00:00+00:002018-11-28T00:00:00+00:00https://rustwasm.github.io/2018/11/28/this-week-in-rust-wasm-009<p>Hello and welcome to another issue of <em>This Week in Rust and WebAssembly</em>!</p> <p><a href="https://rust-lang.org">Rust</a> is a systems language pursuing the trifecta: safety, concurrency, and speed.</p> <p><a href="http://webassembly.org">WebAssembly</a> is a stack-based virtual machine and instruction set. It is fast, safe, portable, and part of the open Web platform. By compiling to WebAssembly, we can run Rust code on the Web!</p> <p>This is a weekly summary of Rust and WebAssembly’s progress and community.</p> <p>Did we miss something? Tweet to us at <a href="https://twitter.com/rustwasm">@rustwasm</a> or <a href="https://github.com/rustwasm/rustwasm.github.io">send us a pull request</a>.</p> <p><strong>Want to get involved in Rust and WebAssembly? <a href="https://github.com/rustwasm/team/blob/master/README.md#get-involved">Join the Rust and WebAssembly working group!</a></strong></p> <!-- TODO: check recent r/rust and users.rust-lang.org posts for "wasm" and "webassembly: --> <!-- https://github.com/rustwasm/team/issues/79 --> <!-- https://www.reddit.com/r/rust/search?q=wasm&sort=relevance&restrict_sr=on&t=month --> <!-- https://www.reddit.com/r/rust/search?q=webassembly&restrict_sr=on&sort=relevance&t=month --> <!-- https://users.rust-lang.org/search?q=wasm%20after%3A2018-06-01 --> <!-- https://users.rust-lang.org/search?q=webassembly%20after%3A2018-06-01 --> <h2 id="news-and-blog-posts">News and Blog Posts</h2> <p><em>Want to make sure something ends up in this list on the next This Week in Rust and WebAssembly? <a href="https://github.com/rustwasm/team/issues/79">Leave a comment on this issue.</a></em></p> <ul> <li><strong><a href="https://rustwasm.github.io/2018/10/24/multithreading-rust-and-wasm.html">Multithreading Rust and WebAssembly</a></strong></li> <li><a href="https://sharadchand.com/2018/10/03/ruukh-framework.html">Introducing the Ruukh Framework.</a> An experimental next-gen frontend framework for the Web in Rust. <a href="https://github.com/csharad/ruukh/">GitHub repository.</a></li> <li>The new website for the <code class="highlighter-rouge">pest</code> PEG parser generator has a nice wasm-based try-it-live demo at the bottom: https://pest.rs/</li> <li><a href="https://frehberg.wordpress.com/webassembly-and-dynamic-memory/">WebAssembly and Dynamic Memory.</a> A comparison of portability of allocators for wasm, featuring <code class="highlighter-rouge">wee_alloc</code>.</li> <li><a href="https://crates.io/crates/simi">Simi</a> is a new, simple framework for building wasm-front-end Web application in Rust.</li> <li><a href="https://sterlingdemille.com/encrusted/">Encrusted</a> is an interpreter for Infocom-era interactive fiction games like Zork that runs in your browser and is built with Rust and WebAssembly.</li> <li><a href="https://egghead.io/courses/using-webassembly-with-rust">Using WebAssembly with Rust</a> is a new, free Video Course on Egghead.</li> <li><a href="https://github.com/Pauan/SaltyBetBot"><code class="highlighter-rouge">Pauan/SaltyBetBot</code></a> is a SaltyBet Bot written entirely in Rust and <code class="highlighter-rouge">stdweb</code> and compiled to Wasm.</li> <li><a href="https://blog.scottlogic.com/2018/10/18/serverless-rust.html">Serverless Rust with AWS Lambda and WebAssembly</a></li> <li><a href="https://blog.cloudflare.com/cloudflare-workers-as-a-serverless-rust-platform/">Serverless Rust with Cloudflare Workers and WebAssembly</a></li> <li><a href="https://github.com/Hywan/php-ext-wasm"><code class="highlighter-rouge">php-ext-wasm</code></a> is a PHP extension written in C, calling a Rust lib through FFI, using <code class="highlighter-rouge">wasmi</code> behind the scene.</li> <li><a href="https://www.reddit.com/r/rust/comments/9t95fd/howto_setting_up_webassembly_on_stable_rust/">HOWTO: Setting up WebAssembly on stable Rust without rustup.</a> Instructions on using raw Rust and Wasm if you happen not to have <code class="highlighter-rouge">rustup</code> available.</li> <li><a href="https://github.com/wasmerio/wasmer">Wasmer</a> is a WebAssembly runtime built on top of Cranelift.</li> <li><a href="https://wasm.fastlylabs.com/">Terrarium</a> is a fork of <a href="https://webassembly.studio/">WebAssembly Studio</a>, except rather than run WebAssembly in your browser, it is deployed to a fastly server.</li> <li><a href="https://github.com/Vurich/runwasm"><code class="highlighter-rouge">runwasm</code></a> is an Emscripten emulation layer built with <code class="highlighter-rouge">wasmi</code>.</li> <li><a href="https://sindrejohansen.no/blog/willow/rust/elm/2018/11/16/willow-elm-in-rust.html">Bringing Elm’s architecture to Rust and Webassembly</a></li> <li><a href="https://cs242.stanford.edu/">Stanford’s CS 242 Programming Languages Class</a> will feature Rust and WebAssembly.</li> <li><a href="https://pragprog.com/book/khrust/programming-webassembly-with-rust">The “Programming WebAssembly with Rust” book</a> by Kevin Hoffman and published by Pragmatic Programmers is in beta and available for pre-order.</li> <li><a href="https://github.com/yiransheng/rust-snake-wasm"><code class="highlighter-rouge">yiransheng/rust-snake-wasm</code></a> is a snake game in Rust and WebAssembly.</li> <li><a href="https://crates.io/crates/console-web"><code class="highlighter-rouge">console-web</code></a> is a crate for writing to the console in wasm using <code class="highlighter-rouge">wasm-bindgen</code>.</li> </ul> <h2 id="updates-from-rustwasm">Updates from <a href="https://github.com/rustwasm"><code class="highlighter-rouge">rustwasm/*</code></a></h2> <ul> <li><a href="https://github.com/rustwasm/wasm-bindgen/blob/master/CHANGELOG.md#0228"><code class="highlighter-rouge">wasm-bindgen</code> 0.2.28 released! 🎉</a></li> <li><a href="https://github.com/rustwasm/wasm-pack/blob/master/CHANGELOG.md#-051"><code class="highlighter-rouge">wasm-pack</code> 0.5.1 released! 🎉</a></li> <li><a href="https://github.com/rustwasm/twiggy/blob/master/CHANGELOG.md#030">Twiggy 0.3.0 released! 🎉</a></li> <li>There are two new reference sections in the Rust and Wasm book: <ol> <li><a href="https://rustwasm.github.io/book/reference/which-crates-work-with-wasm.html">Which Crates Will Work with Rust and WebAssembly?</a></li> <li><a href="https://rustwasm.github.io/book/reference/add-wasm-support-to-crate.html">How to Add WebAssembly Support to a General-Purpose Crate</a></li> </ol> </li> </ul> <h2 id="requests-for-contribution">Requests for Contribution</h2> <ul> <li><a href="https://github.com/rustwasm/team/blob/master/README.md#get-involved"><strong>Join the Rust and WebAssembly Working Group!</strong></a> <ul> <li><a href="https://github.com/issues?q=is%3Aopen+is%3Aissue+user%3Arustwasm+archived%3Afalse+label%3A%22good+first+issue%22">All issues labeled “good first issue” in the <code class="highlighter-rouge">rustwasm/*</code> repositories</a></li> <li><a href="https://github.com/issues?q=is%3Aopen+is%3Aissue+user%3Arustwasm+archived%3Afalse+label%3A%22help+wanted%22">All issues labeled “help wanted” in the <code class="highlighter-rouge">rustwasm/*</code> repositories</a></li> </ul> </li> </ul> <h2 id="jobs">Jobs</h2> <ul> <li><a href="https://www.fastly.com/about/jobs/apply?gh_jid=1320541">Fastly is hiring</a> for work on their native WebAssembly compiler, which is written in Rust, based on <a href="https://github.com/CraneStation/cranelift">Cranelift</a></li> </ul> <!-- ## `rustwasm` Projects Activity --> <!-- Recently merged pull requests to projects in the [`rustwasm` GitHub --> <!-- organization][rustwasm-org]: --> <!-- [rustwasm-org]: https://github.com/rustwasm --> <!-- TODO: insert the output of `pulls_since -o rustwasm -s dd.mm.yyyy` here, where --> <!-- "dd.mm.yyyy" is the date the *last* newsletter was published. See --> <!-- https://github.com/budziq/pulls_since or run `cargo install pulls_since`. -->Hello and welcome to another issue of This Week in Rust and WebAssembly!