Skip to content

Commit e90d1a5

Browse files
committed
rust: add README.md
1 parent 1cdd86a commit e90d1a5

File tree

1 file changed

+114
-0
lines changed

1 file changed

+114
-0
lines changed

runtime/rust/README.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
## Rust
2+
3+
### Versions
4+
5+
- New versions every ~6 weeks
6+
- 1.91.1 released 2025-11-10
7+
- 1.91 released 2025-10-30
8+
- 1.89.0 released 2025-08-07
9+
- Rust Editions - Rust uses editions to make backwards-incompatible changes. Editions are a mechanism for opt-in changes that may otherwise pose a backwards compatibility risk.
10+
- New Editions every ~3 years
11+
- Rust 2015, the default edition from Rust 1.0.
12+
- Rust 2018, which added path and module system changes and was released alongside 1.31 in December 2018.
13+
- Rust 2021, released alongside 1.56 in October 2021.
14+
- Rust 2024, released alongside 1.85 in February 2025.
15+
16+
### Considerations
17+
18+
1. "Engineers cited performance, lack of a garbage collector, safety, and pleasantness of working in the language as reasons for the adoption."
19+
20+
2. "Hoare has described Rust as targeted at frustrated C++ developers."
21+
22+
3. "Stability as a Deliverable" <https://blog.rust-lang.org/2014/10/30/Stability/>
23+
24+
4. Helpful errors:
25+
26+
```
27+
error[E0599]: no method named \`to<sub>str</sub>\` found for enum
28+
56 | assert<sub>eq</sub>!(msg.to<sub>str</sub>().unwrap(), "foo");
29+
help: there is a method \`to<sub>string</sub>\` with a similar name
30+
```
31+
32+
5. rustdoc generates docs from source <https://doc.rust-lang.org/rustdoc/>
33+
34+
### Tips
35+
36+
1. Env settings
37+
38+
```
39+
CARGO_TERM_COLOR: always
40+
```
41+
42+
2. Debian install
43+
44+
```
45+
apt install rustup
46+
rustup default stable
47+
```
48+
49+
### Basic build/test loop
50+
51+
```
52+
cargo build
53+
cargo test
54+
cargo clean
55+
cargo build --locked --release --all-targets
56+
```
57+
58+
### Third-party packages
59+
60+
1. Cargo (crates.io)
61+
62+
<https://crates.io/>
63+
64+
1. Adding to project
65+
66+
Cargo.toml:
67+
68+
```
69+
[package]
70+
name = "hello-world"
71+
version = "0.1.0"
72+
edition = "2021"
73+
74+
[dependencies]
75+
regex = "1.0"
76+
```
77+
78+
### Native Interoperability
79+
80+
<https://docs.rust-embedded.org/book/interoperability/c-with-rust.html>
81+
82+
- C headers, externs, static link with LLVM
83+
- There is a tool called bindgen which will generate Rust interfaces to C libs
84+
- Shared lib loading: <https://docs.rs/libloading/latest/libloading/> For shared libs written in Rust or another language
85+
- Working with dynamically loaded libraries often involves using the unsafe keyword
86+
87+
### Websockets example
88+
89+
<https://lib.rs/crates/tungstenite>
90+
91+
```
92+
use tungstenite::{connect, Message};
93+
let (mut socket, _response) =
94+
connect("ws://corefx-net-http11.azurewebsites.net/WebSocket/EchoWebSocket.ashx")
95+
.expect("Can't connect");
96+
socket
97+
.send(Message::Text("Hello WebSocket".into()))
98+
.unwrap();
99+
let msg = socket.read().expect("Error reading message");
100+
```
101+
102+
### Cross-platform compile from linux
103+
104+
```
105+
rustup target list
106+
cargo build --target x86_64-unknown-linux-gnu
107+
cargo build --target x86_64-apple-darwin
108+
cargo build --target x86_64-pc-windows-msvc
109+
```
110+
111+
### Introspection
112+
113+
Not built in, but possible with macros
114+

0 commit comments

Comments
 (0)