RUST

hogeol·2025년 2월 14일
0

RUST

목록 보기
1/1

BUILD

  • cargo new
    • Create new project
  • cargo build
    • Build the code (the executable file is generated in target/debug)
    • Don't optimize the code (build speed is faster than release)
  • cargo build -- release : build the code with release
    • Build the code (the executable file is generated in target/release)
    • Optimize the code (build speed is slower than debug, but the code is fater than normal build)
  • cargo run
    • Build the code and execute the executable file.
  • cargo check
    • Check the project error without generate binary file.
  • cargo update
    • Update the dependencies impelmented in Cargo.toml (Ignore Cargo.lock)
      (If the crate is 0.8.x version, the update is ignore 0.9.x release version, If the 0.8.6 and 0.9.0 is both released, the crate will be 0.8.6 version in Cargo.toml with cargo update. If you want to use 0.9.0 version, you need manually edit Cargo.toml)

      Cargo.toml
      with cargo update

      [dependencies]
      rand = 0.8.5

      to

      [dependencies]
      rand = 0.8.6

      If you want to 0.9.0 version, manually update the Cargo.toml

      [dependencies]
      rand = 0.9.0
  • Carco.lock file
    • Don't automatically upgrade dependencies version.

ALIAS

alias cb='cargo build'
alias cbr='cargo build --release'
alias cr='cargo run'
alias cc='cargo check'
alias cn='cargo new'

Variable

The variable is immutable default, If you want to edit the assigned value, you need to add mut when declare the variable.
Immutable

let a = 10

Mutable

let mut a = 10

interger size


Reference

RUST start - https://doc.rust-kr.org/title-page.html
Open source - https://crates.io/

0개의 댓글