Skip to content

Instantly share code, notes, and snippets.

@1UC1F3R616
Last active December 26, 2021 06:27
Show Gist options
  • Save 1UC1F3R616/6b584da23e617b35fd6df2ce65c11ec3 to your computer and use it in GitHub Desktop.
Save 1UC1F3R616/6b584da23e617b35fd6df2ce65c11ec3 to your computer and use it in GitHub Desktop.

What made me curious about Rust

Installation on Linux

  • curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  • source $HOME/.cargo/env
  • export PATH="$HOME/.cargo/bin:$PATH"

Some points

  • ahead-of-time compiled language
  • Cargo is Rust’s build system and package manager
    • building your code, downloading the libraries your code depends on, and building those libraries
  • packages of code (libraries/dependencies) are referred to as crates

Some commands

  • rustc hello_world.rs compiles rust code
  • rustfmt hello_world.rs format rust code
@1UC1F3R616
Copy link
Author

1UC1F3R616 commented Dec 25, 2021

Creating a project with cargo

  • cargo new hello_cargo --bin
  • cd hello_cargo
  • cargo build
  • cargo run
  • cargo check
  • cargo build --release
  • cargo update fetch the latest SegVer and note down in cargo.lock
  • cargo doc --open build doc for ur crates

@1UC1F3R616
Copy link
Author

1UC1F3R616 commented Dec 25, 2021

Some more points

The :: syntax in the ::new line indicates that new is an associated function
of the String type. An associated function is implemented on a type, in this
case String , rather than on a particular instance of a String . Some languages
call this a static method.
Switching from an expect call to a match expression is one way of moving from crashing on an error to handling the error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment