A collection of various web frameworks and other web-related tools in Rust. The ones I have started to review are in bold. Based on the replies to the question I asked on Reddit: Which web framework do you use in Rust? I can say that most o...
Part of the series about the Rocket web framework. Create crate In order to have a Rocket, we need to create a regular Rust crate. cargo new hello-world cd hello-world Setup dependencies Add rocket = "0.5.0" to the Cargo.toml file: examples...
Simple example of the max function We start with a simple function that returns the bigger of two values. Basically we are re-implementing the max function as an example. fn main() { let x: i8 = 25; let y: i8 = 42; println!("{}", bigger(x,...
tiny_http is, well, a tiny crate to create web applications. In this series of articles we are going to see how to use it to build a simple web application. Hello World - set Content-type to text/html. Server, http, incoming_requests, Respo...
Unlike Python and several other programming languages, Rust does not allow setting default values to function parameters. Luckily with a little bit of macro-writing we can imitate it. Here is the whole example examples/default-arguments/src...
In some code you will see a construct that looks like this: parse::<i32>() or this collect::<Vec<&str>>() or maybe this: collect::<Vec<_>>() These all use the Turbofish syntax ::<>. When is it used? In some cases Rust can deduce the type of...
Meetup Stats I wanted to know the relative sizes of the various Rust-specific Meetup groups so I collected them into a YAML file and then generated this page. If you are interested which one is meeting in the next month or so check out This...
If we don't say what a function returns, it is expected to return (): fn say_hi(name: &str) { println!("Hello {}", name); } However, there are function that never return. For example because they call the panic! macro or the std::process::e...
Loco is called the one-person framework for Rust for side-projects and startups. I saw it mentioned in on of the local Rust groups, so I thought I would give it a try. I am using loco-cli 0.1.3. By the time you are reading this, there might...
We already saw how to embed a simple string in our Rust application and also how to use preprocessing to embed a list of values. Now we need to embed a simple CSV file that looks like this: examples/embedded-simple-csv-file/data/languages.c...
Here is one thing for which I like Rust. Recently, as I wrote some code, I made a typo in a variable name: examples/code_with_typo.rs fn main() { zero(3); zero(0); } fn zero(n: i32) { if i == 0 { println!("zero"); } else { println!("{} is n...