From JavaScript to Rust

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Map common JavaScript and node.js workflows to the Rust ecosystem

Author(s): Jarrod Overson, Vino Technologies

Language: English
Pages: 161
Tags: nodejs, rust, javascript

Go From JavaScript to Rust
Table of Contents
Preface
A note on contributions:
Cover image
1. Introduction
1.1. A guide to Rust from a node.js developer’s perspective.
1.2. Wait, why does anyone need to learn anything but JavaScript?
1.3. Why Rust?
1.4. How to use this book
2. Installing rust with rustup
2.1. rust-toolchain.toml
2.2. Next steps
3. From npm to cargo
3.1. Introduction
3.2. npm to cargo mapping
3.3. Wrap-up
4. Setting up Visual Studio Code
4.1. Introduction
4.2. Core language setup
4.3. Additional extensions
4.4. Wrap-up
5. Hello World (and your first two WTFs)
5.1. Introduction
5.2. Strings WTF #1
5.3. Strings WTF #2
5.4. Wrap-up
6. Borrowing & Ownership
6.1. Introduction
6.2. Wrap-up
7. Strings, Part 1
7.1. Introduction
7.2. Additional links
7.3. Rust strings in a nutshell
7.4. Wrap-up
8. Language Part 1: Syntax & Differences
8.1. Introduction
8.2. Wrap-up
9. From objects and classes to HashMaps and structs
9.1. Introduction
9.2. From Map to HashMap
9.3. From objects and classes to structs
9.4. Wrap-up
10. Enums and Methods
10.1. Introduction
10.2. Wrap-up
11. From Mixins to Traits
11.1. Introduction
11.2. Wrap-up
12. The Module System
12.1. Introduction
12.2. "How do I import a file in Rust?"
12.3. "How do I import functions from other modules?"
12.4. The pieces of the Rust Module System
12.5. Wrap-up
13. Strings, Part 2
13.1. Introduction
13.2. Should I use &str or String for my function arguments?
13.3. Wrap-up
14. Demystifying Results & Options
14.1. Introduction
14.2. Option recap
14.3. Result
14.4. The problem with .unwrap()
14.5. Wrap-up
15. Managing Errors
15.1. Introduction
15.2. Wrap-up
16. Closures
16.1. Introduction
16.2. Closure syntax comparison
16.3. Wrap-up
17. Lifetimes, References, and 'static
17.1. Introduction
17.2. Lifetimes vs lifetime annotations
17.3. Lifetime elision
17.4. The 'static lifetime
17.5. Wrap-up
18. Arrays, Loops, and Iterators
18.1. Introduction
18.2. Recap: vec![], Vec, and VecDeque
18.3. Loops
18.4. Labels, break, continue
18.5. break & loop expressions
18.6. Intro to Rust Iterators
18.7. Translating Array.prototype methods
18.8. Wrap-up
19. Async in Rust
19.1. Introduction
19.2. Wrap-up
20. Tests and Project Structure
20.1. Introduction
20.2. Creating your workspace
20.3. Starting a library
20.4. Creating a CLI that uses your library
20.5. Running your CLI from your workspace
20.6. Additional reading
20.7. Wrap-up
21. CLI Arguments and Logging
21.1. Introduction
21.2. Adding debug logs
21.3. Adding CLI Arguments
21.4. Putting it all together.
21.5. Additional reading
21.6. Wrap-up
22. Building and Running WebAssembly
22.1. Introduction
22.2. Building a WebAssembly module
22.3. Additional reading
22.4. Wrap-up
23. Handling JSON
23.1. Introduction
23.2. Enter serde
23.3. Extending our CLI
23.4. Representing arbitrary JSON
23.5. Additional reading
23.6. Wrap-up
24. Cheating The Borrow Checker
24.1. Introduction
24.2. Mutex & RwLock
24.3. Async
24.4. Additional reading
24.5. Wrap-up
25. Crates & Valuable Tools
25.1. Introduction
25.2. Crates
25.3. Additional reading
25.4. Wrap-up