Skip to content

Rust has a steep learning curve. So I will learn it, one day at a time.

Notifications You must be signed in to change notification settings

psyklopp/Learn-Rust-for-Hacking

Repository files navigation

Learn-Rust-for-Hacking

Having studied computer science, I think this is time to learn one language for good. Although I have a lot of experience using Java, I want to pivot to the security side and Rust seems to be the perfect choice (for me). There are a lot of languages but since I want to start from the very beginning, why not choose a language which is fast, efficient and memory-safe.

I have no idea what to expect from Rust but will document the journey.

My main sources for help, reference and documentation will be Rust by Example and Black Hat Rust.

Official Rust Docs

Day #1

Day #2

Day #3

Day #4

  • Implementing fmt::Display for the first time

Day #5

Day #6

Day #7

Day #8

Day #9

  • Completed the activities in 3.1 - Structures

Day #10

Day #11

  • Did some coding using use for enums. 3.2.1 use

Day #12

Day #13

Day #14

Takeaway tips
  • We can create a project using cargo new.
  • We can build a project using cargo build.
  • We can build and run a project in one step using cargo run.
  • We can build a project without producing a binary to check for errors using cargo check.
  • Instead of saving the result of the build in the same directory as our code, Cargo stores it in the target/debug directory.

Day #15

Takeaway tips
  • Variable is immutable by default.
  • However we can use mut to make a variable mutable.
  • Constants aren’t just immutable by default—they’re always immutable.
  • Constants are valid for the entire time a program runs, within the scope in which they were declared.

Day 16

Takeaway tips
  • Difference between mut and shadowing is that because we’re effectively creating a new variable when we use the let keyword again.
  • First variable is shadowed by the second, which means that the second variable is what the compiler will see when you use the name of the variable.

Day 17

Takeaway tips
  • Rust is a statically typed language, which means that it must know the types of all variables at compile time.
  • A scalar type represents a single value. Rust has four primary scalar types: integers, floating-point numbers, Booleans, and characters.

Day 18

  • Finished 3.2. Data Types.
Takeaway tips
  • Rust has two primitive compound types: tuples and array.
  • A tuple is a general way of grouping together a number of values with a variety of types into one compound type. Tuples have a fixed length: once declared, they cannot grow or shrink in size.
  • Unlike a tuple, every element of an array must have the same type. Unlike arrays in some other languages, arrays in Rust have a fixed length.

Day 19

Takeaway tips
  • In function signatures, you must declare the type of each parameter.
  • Statements are instructions that perform some action and do not return a value.
  • Expressions evaluate to a value.
  • Expressions do not include ending semicolons. If you add a semicolon to the end of an expression, you turn it into a statement, and it will then not return a value.

Day 20

Takeaway tips
  • You must be explicit and always provide if with a Boolean as its condition.
  • In the if, else if and else blocks, if the types are mismatched, it will throw an error.

Day 21

Takeaway tips
  • We can use break your_return_value_here to break from the loop and return a value.
  • Nothing else! It is similar to loops in JAVA or C++.

About

Rust has a steep learning curve. So I will learn it, one day at a time.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages