Skip to content

Commit 6da0644

Browse files
authored
feat: day05
1 parent 5961dd7 commit 6da0644

File tree

17 files changed

+6844
-0
lines changed

17 files changed

+6844
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/target
2+
**/*.rs.bk
3+
Cargo.lock
4+
bin/
5+
pkg/
6+
wasm-pack.log
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
[package]
2+
name = "wasm-aoc"
3+
version = "0.1.0"
4+
authors = ["subesokun"]
5+
edition = "2018"
6+
7+
[lib]
8+
crate-type = ["cdylib", "rlib"]
9+
10+
[features]
11+
default = ["console_error_panic_hook"]
12+
13+
[dependencies]
14+
wasm-bindgen = "0.2.63"
15+
16+
# The `console_error_panic_hook` crate provides better debugging of panics by
17+
# logging them with `console.error`. This is great for development, but requires
18+
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
19+
# code size when deploying.
20+
console_error_panic_hook = { version = "0.1.6", optional = true }
21+
22+
# `wee_alloc` is a tiny allocator for wasm that is only ~1K in code size
23+
# compared to the default allocator's ~10K. It is slower than the default
24+
# allocator, however.
25+
#
26+
# Unfortunately, `wee_alloc` requires nightly Rust when targeting wasm for now.
27+
wee_alloc = { version = "0.4.5", optional = true }
28+
29+
[dependencies.web-sys]
30+
version = "0.3"
31+
features = ["console"]
32+
33+
[dependencies.js-sys]
34+
version = "0.3.45"
35+
36+
[dev-dependencies]
37+
wasm-bindgen-test = "0.3.13"
38+
39+
[profile.release]
40+
# Tell `rustc` to optimize for small code size.
41+
opt-level = "s"
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
== Rust + WASM
2+
3+
Runs Rust directly in your browser ✨
4+
5+
Try it live in your browser, https://subesokun.github.io/aoc-2020/day05/wasm-rust/subesokun/[day05]
6+
7+
=== First Star
8+
9+
[source,rust, linenums]
10+
----
11+
include::src/solution.rs[tags=star1]
12+
----
13+
14+
=== Second Star
15+
16+
[source,rust, linenums]
17+
----
18+
include::src/solution.rs[tags=star2]
19+
----
20+
21+
=== Run locally
22+
23+
> Hint: When running in Codespaces make sure that your terminal is running in a Bash session (just enter "bash" to start it)
24+
25+
```
26+
# in a new terminal
27+
./build-wasm.sh # auto rebuilds on changes
28+
29+
# in a new terminal
30+
cd www
31+
npm ci
32+
npm start # auto rebuilds on changes
33+
34+
# In your browser open the localhost:8080 or in Codespaces the provided url
35+
# -> Have a look in your console for the output
36+
# Hint: Auto-reload of web page works only on localhost as Codespaces blocks the WebSocket connection for some reason
37+
```
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
wasm-pack build
4+
cargo watch -s 'wasm-pack build'

0 commit comments

Comments
 (0)