Menu

Tree [a91a1c] master /
 History

HTTPS access


File Date Author Commit
 .vscode 2024-09-10 M. 'howlingmad' Neifer M. 'howlingmad' Neifer [3d79de] Add VS Code setting for AsciiDoc extension
 doc 2024-09-10 M. 'howlingmad' Neifer M. 'howlingmad' Neifer [742527] Add FFI example for C
 hello-pyo3 2024-08-14 M. 'howlingmad' Neifer M. 'howlingmad' Neifer [9b4ebd] Add PyO3 example
 hello-tokio 2022-10-01 M. 'howlingmad' Neifer M. 'howlingmad' Neifer [c9a8ff] Rename package
 hello-warp 2022-07-15 M. 'howlingmad' Neifer M. 'howlingmad' Neifer [3a4c14] Add Warp example
 hello-wasm 2022-01-16 M. 'howlingmad' Neifer M. 'howlingmad' Neifer [26738c] Add Tokio example
 hello_c 2024-09-23 M. 'howlingmad' Neifer M. 'howlingmad' Neifer [3259b0] Add doc link
 hello_clargs 2024-08-14 M. 'howlingmad' Neifer M. 'howlingmad' Neifer [6238ef] Add command-line arguments example
 hello_rust 2024-09-23 M. 'howlingmad' Neifer M. 'howlingmad' Neifer [d0d6eb] Add error handling example
 mhn-verb-service 2023-03-09 M. 'howlingmad' Neifer M. 'howlingmad' Neifer [9c027e] Cleanup code
 .editorconfig 2024-08-14 M. 'howlingmad' Neifer M. 'howlingmad' Neifer [cf5085] Add EditorConfig file
 .gitignore 2024-08-14 M. 'howlingmad' Neifer M. 'howlingmad' Neifer [a02990] Remove empty line
 .markdownlint.json 2024-09-04 M. 'howlingmad' Neifer M. 'howlingmad' Neifer [497f33] Disable rule for long lines
 Dockerfile 2021-08-29 M. 'howlingmad' Neifer M. 'howlingmad' Neifer [8fafcf] Added Rust examples from general repository.
 LICENSE 2024-08-14 M. 'howlingmad' Neifer M. 'howlingmad' Neifer [b5719c] Update copyright years
 README.md 2024-11-02 M. 'howlingmad' Neifer M. 'howlingmad' Neifer [a91a1c] Add links to C2Rust and Unleash
 docker-build.sh 2021-08-29 M. 'howlingmad' Neifer M. 'howlingmad' Neifer [8fafcf] Added Rust examples from general repository.
 docker-run.sh 2021-08-29 M. 'howlingmad' Neifer M. 'howlingmad' Neifer [8fafcf] Added Rust examples from general repository.

Read Me

Rust Examples

Collection of Rust code examples for my blog F7L8C9.

Licensed under the MIT License. See file LICENSE.

Cargo

Rust build tool and package manager. Select a Rust edition in the Cargo.toml
file of your package. An edition is a curated set of dependencies that work well
together. Somewhat like a Linux distribution.

Building with Cargo assumes that a linker has been installed already. If not, it
can be installed on Linux with sudo apt install build-essential.

  • Creating a new package with cargo new <package_name>
    • Add --bin to create a binary program
    • Add --lib to create a library
    • Add --vcs none to skip Git repository initialization
  • Build package with cargo build
  • Run package with cargo run
  • Test package with cargo test
  • Run rustfmt against package with cargo fmt
  • Build documentation for package with cargo doc
  • Publish a library to crates.io with cargo publish
  • Update dependencies to the latest version with cargo update (updates Cargo.lock file)

Crate registry is at crates.io. Documentation for crates
is at Docs.rs.

If you’re building a non-end product, such as a rust library that other rust
packages will depend on, put Cargo.lock in your .gitignore. If you’re
building an end product, which are executable like command-line tool or an
application, or a system library with crate-type of staticlib or cdylib, check
Cargo.lock into git. See Cargo FAQ.

Rustup

Show the active and installed toolchains or profiles with rustup show.

Check for updates to toolchains and rustup with rustup check.

Update environment to latest stable version with rustup update stable.

WebAssembly

Use wasm-pack build to create a package.

Tips

Rust allows trailing commas.

struct User {
  name: String,
  age: u8,
}

Tasks

  • Containerize verb service
  • Update Wasm example
  • Add C interface example
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.