node-to-rust
node-to-rust copied to clipboard
trafficstars
From JavaScript to Rust ebook
This repository houses an ebook-ified version of the 24+ post series started on vino.dev.
How to build
The ebook is built using asciidoctor and requires ruby >2.3.
Install the ruby dependencies via make deps
$ make deps
Build a PDF via the command make book
$ make book
Running code and projects
All code are housed in the src/ directory.
Day 4
cargo run -p day-4-hello-worldcargo run -p day-4-strings-wtf-1- intentionally does not compile.cargo run -p day-4-strings-wtf-2- intentionally does not compile.
Day 5
Reassigning
- JS:
node javascript/day-5/let-vs-const/reassigning.js - Rust:
cargo run -p day-5-let-vs-const --bin reassigning cargo run -p day-5-let-vs-const --bin reassigning-wrong-type- intentionally does not compile
Borrowing
cargo run -p day-5-borrowing --bin borrowcargo run -p day-5-borrowing --bin mutable-borrow- intentionally does not compile
Day 6
cargo run -p day-6-loads-of-strs --bin 200-unique-printscargo run -p day-6-loads-of-strs --bin 200-printscargo run -p day-6-loads-of-strs --bin 200-empty-printscargo run -p day-6-loads-of-strs --bin one-print
Day 7
Syntax
cargo run -p day-7-syntax
Day 8
Maps
ts-node javascript/day-8/src/maps.tscargo run -p day-8-maps
Structs
ts-node javascript/day-8/src/structs.tscargo run -p day-8-structs
Day 9
Day 10
Day 11
Modules
cargo run -p day-11-modules --bin nested-submodulescargo run -p day-11-traffic-light
Day 12
cargo run -p day-12-impl-tostringcargo run -p day-12-impl-asref-str
Day 13
cargo run -p day-13-optioncargo run -p day-13-resultcargo run -p day-13-question-mark
Day 14
From/Into
cargo run -p day-14-from-into
Errors
These examples require setting an environment variable. How to do that in your environment might look different.
MARKDOWN=README.md cargo run -p day-14-boxed-errorsMARKDOWN=README.md cargo run -p day-14-custom-error-typeMARKDOWN=README.md cargo run -p day-14-thiserrorMARKDOWN=README.md cargo run -p day-14-error-chainMARKDOWN=README.md cargo run -p day-14-snafu
Day 16
Closures
cargo run -p day-15-closures
Day 16
Type differences
cargo run -p day-16-type-differences --bin impl-ownedcargo run -p day-16-type-differences --bin impl-borrowed
'static
cargo run -p day-16-static- intentionally does not compilecargo run -p day-16-static-bounds- intentionally does not compile
Lifetime elision
cargo run -p day-16-elision
Unsafe pointers
cargo run -p day-16-unsafe-pointers
Day 17
Arrays
cargo run -p day-17-arraysts-node javascript/day-17/src/arrays.ts
Iterators
cargo run -p day-17-iteratorsts-node javascript/day-17/src/iterators.ts
Names example
cargo run -p day-17-names
Day 18
cargo run -p day-18-async --bin send-synccargo run -p day-18-async --bin simplecargo run -p day-18-async --bin lazycargo run -p day-18-async --bin fscargo run -p day-18-async --bin async-blocks
Day 19
First you must cd into crates/day-19/project
cargo testcargo run -p cli
Day 20
First you must cd into crates/day-20/project
RUST_LOG=cli=debug cargo run -p cli
Day 21
waPC runner
First you must cd into crates/day-21/project
cargo run -p cli -- crates/my-lib/tests/test.wasm hello "Potter"
waPC guest (hello)
First you must cd into crates/day-21/wapc-guest
- Build with
make
Day 22
Serde
cargo run -p day-22-serde
waPC runner
First you must cd into crates/day-22/project
cargo run -p cli -- crates/my-lib/tests/test.wasm hello hello.jsoncargo run -p cli -- ./blog.wasm render ./blog.json
waPC guest (blog)
First you must cd into crates/day-22/wapc-guest
- Build with
make
Day 23
cargo run -p day-23-rc-arc --bin referencescargo run -p day-23-rc-arc --bin rccargo run -p day-23-rc-arc --bin arccargo run -p day-23-rc-arc --bin rwlockcargo run -p day-23-rc-arc --bin async- intentionally does not compile
License
Book: Creative Commons BY-NC 4.0 Code: Creative Commons BY 4.0