First timid steps in Rust

I’m working on a new site https://highperformancewebfonts.com/ where I’m doing everything wrong. E.g. using a joke-y client-side-only rendering of articles from .md files (Hello Lizzy.js) Since there’s no static generation, there’s no RSS feed. And since someone asked, I decided to add it. But in the spirit of learning-while-doing I thought I should do the […]


This content originally appeared on phpied.com and was authored by Stoyan

I'm working on a new site https://highperformancewebfonts.com/ where I'm doing everything wrong. E.g. using a joke-y client-side-only rendering of articles from .md files (Hello Lizzy.js)

Since there's no static generation, there's no RSS feed. And since someone asked, I decided to add it. But in the spirit of learning-while-doing I thought I should do the feed generation in Rust. A language I know nothing about.

So here are my first steps in Rust for posterity. BTW the end result is https://highperformancewebfonts.com/feed.xml

1. Install Rust

The recommended install is via rustup utility. This page https://www.rust-lang.org/tools/install has the instructions:

$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Next restart the terminal shell or run:

$ . "$HOME/.cargo/env"

Check if installation was ok:

$ rustc --version
rustc 1.84.0 (9fc6b4312 2025-01-07)

2. A new project

A utility called Cargo seems like the way to go. Looks like it's a package manager, an NPM of Rust:

$ cargo new russel && cd russel

(The name of my program is "russel", from "rusty", from "rust". Yeah, I'll see myself out.)

3. Add dependencies to Cargo.toml

And Cargo.toml looks like a config file similar in spirit to package.json and similar in syntax to a php.ini. Since I'll need to write an RSS feed, a package called rss would be handy.

[package]
name = "russel"
version = "0.1.0"
edition = "2021"

[dependencies]
rss = "2.0.0"

Running $ cargo build after a dependency update seems necessary.

To explore packages, a crates.io site looks appropriate e.g. https://crates.io/crates/rss as well as docs.rs, e.g. https://docs.rs/rss/2.0.11/rss/index.html

4. All ok so far?

The command `cargo new russel` from the previous step created a hello-world program, we can test it by running:

$ cargo run

This should print "Hello, world!"

Nice!

5. Tweaks in src/main.rs

Let's just test we can make any changes and see the result. Seeing is believing!

Open src/main.rs, loos at this wonderful function:

fn main() {
  println!("Hello, world!");
}

Replace the string with "Bello, world". Save. Run:

$ cargo run

If you see the "Bello", the setup seems to be working. Rejoice!

6. (Optional, VSCode only) install rust-analyzer

It's pretty helpful.

Go Rust in peace!

https://en.wikipedia.org/wiki/Rust_in_Peace


This content originally appeared on phpied.com and was authored by Stoyan


Print Share Comment Cite Upload Translate Updates
APA

Stoyan | Sciencx (2025-02-01T00:00:43+00:00) First timid steps in Rust. Retrieved from https://www.scien.cx/2025/02/01/first-timid-steps-in-rust/

MLA
" » First timid steps in Rust." Stoyan | Sciencx - Saturday February 1, 2025, https://www.scien.cx/2025/02/01/first-timid-steps-in-rust/
HARVARD
Stoyan | Sciencx Saturday February 1, 2025 » First timid steps in Rust., viewed ,<https://www.scien.cx/2025/02/01/first-timid-steps-in-rust/>
VANCOUVER
Stoyan | Sciencx - » First timid steps in Rust. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/02/01/first-timid-steps-in-rust/
CHICAGO
" » First timid steps in Rust." Stoyan | Sciencx - Accessed . https://www.scien.cx/2025/02/01/first-timid-steps-in-rust/
IEEE
" » First timid steps in Rust." Stoyan | Sciencx [Online]. Available: https://www.scien.cx/2025/02/01/first-timid-steps-in-rust/. [Accessed: ]
rf:citation
» First timid steps in Rust | Stoyan | Sciencx | https://www.scien.cx/2025/02/01/first-timid-steps-in-rust/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.