Rust is a language that I’ve been in love with for ages.

It’s also one of the most frustrating languages I’ve ever used. This is both because it has a very steep learning curve, and I’ve never written enough rust to actually be good at it.

It also has the best documentation of any language.

Swift/iOS Interop

Follow this article

Add the iOS architectures to rustup, as well as the tools for building universal iOS binaries (cargo-lipo) and C headers from rust (cbindgen).

rustup target add aarch64-apple-ios armv7-apple-ios armv7s-apple-ios x86_64-apple-ios i386-apple-ios
cargo install cargo-lipo
cargo install cbindgen

Serializing json in rust.

Follow this guide using serde.


Add to Cargo.toml’s [Dependencies] section:

serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

Make your struct derive Serialize, and pass it to serde_json::to_string()

struct Thing {
    x: i32

fn main() {
    let thing = Thing { a: 1 }
    println!("{}", serde_json::to_string(&thing).unwrap());

Rust on an AVR microcontroller

Source-ish: Rust on Arduino.

You can also use this to abstract for pretty much any AVR microcontroller. I have enough bare microcontrollers to last me a lifetime.

🚨 Warning, this content is out of date and is included for historical reasons.

There’s a bug in the rust compiler right now and you can’t use a rust toolchain after 2021-01-07. To mitigate this, add the following to your project’s Cargo.toml:

channel = "nightly-2021-01-07"
components = ["rust-src"]

Also check out avr-rust/ruduino for a library that provides reusable components for an arduino uno/atmega 328p.

Last updated: 2023-08-07 13:26:13 -0700