Learn Rust ๐ฆ
- home
- 150k-250k
- jobs
- rust-lang.org
- wikipedia
Rust is a multi-paradigm, general-purpose programming language designed for performance and safety, especially safe concurrency.
Companies and DAOs like Rated, Stacks Foundation, Solana Labs, Blocknative, Findora Foundation, Evmos, Winter, Flashbots, Fedi and Fuel Labs use Rust to work on Rated, Stacks, Blocknative, Findora, Evmos, Winter, Flashbots, Fedi, Sway and Iron Fish.
Conquer the basics of Rust here and go pro once you get the hang of it. Average salaries for Rust developers are approximately $150k-250k/yr.
Variables are declared like this:
let port: u16 = 8333; // unsigned 16-bit integer
Rust has many types (these are only some):
u8, u16, u32, u64, u128 // unsigned integers
i8, i16, i32, i64, i128 // signed integers
usize, isize // machine address sized integers
f32, f64 // floating-point numbers
bool // boolean true or false
char // unicode characters
Changing a variable will not work:
let port: u16 = 8333;
port = 8334; // error: cannot assign twice to immutable variable `port`
Because we first have to declare it as mutable:
let mut port: u16 = 8333;
port = 8334; // works now
You can drop the type and Rust will infer it:
let mut port = 8333;
port = 8334; // still works
Use an ampersand to get a reference, and a star to dereference:
let port = 8333;
let port_ref = &port;
println!("{}", *port_ref); // 8333
This is an array:
let ports = [8333, 8334, 8335];
If you need a big array, use a shorthand notation:
let ports = [0; 1000]; // 1k length filled with zeros
Arrays are not too fun because their length is part of its type and fixed at compile time. If you need a variable-length array, use a vector instead:
let mut ports = vec![8333, 8334];
ports.push(8335);
Loop through a vector using its iterator:
for port in ports.iter() {
println!("port is: {}", port);
}
Rust has two types of strings:
let name1 = "Bitcoin"; // this is a `&str`
let name2 = "Bitcoin".to_string(); // this is a `String`
A &str
is a slice that points to a valid UTF-8 sequence, whereas a String
is stored as a vector of bytes that can grow:
fn print_and_return_count(name: &str) -> usize { // received as a `&str`
println!("String is {}", name);
name.chars().count()
}
let name = "Bitcoin".to_string(); // this is a `String`
let count = print_and_return_count(&name);
println!("{} is {} char(s) long", name, count);
// Output:
// String is Bitcoin
// Bitcoin is 7 char(s) long
Rust has the concept of ownership:
let name = "Bitcoin".to_string();
let new_name = name;
// error: the value has moved from `name` to `new_name`
println!("{}", name);
Therefore, you have to copy the value if you'd like to use it:
let name = "Bitcoin".to_string();
let new_name = name.clone();
Company | Using | Activity | Looking For | |
---|---|---|---|---|
Company | Using | Activity | Looking For | |
Rust, Terraform, โฆ | apply | |||
Rust, GCP, AWS, Redis, โฆ | apply | |||
Rust, GCP, AWS, Azure, โฆ | apply | |||
Rust, Go, Solidity, โฆ | apply | |||
Rust, Node, C++, โฆ | apply | |||
Rust, GCP, AWS, โฆ | apply | |||
Rust, Node, Solidity, โฆ | apply | |||
Rust, Python, Go, โฆ | apply | |||
Rust | apply | |||
Rust, Go, C++, โฆ | apply |