# プログラミング言語 Rust メモ

**URL:** <https://forum.ficusonline.com/t/topic/496>\
**Category:** Programming\
**Created:** [2023 年 10 月 14 日午後 8:11 UTC](https://forum.ficusonline.com/t/topic/496 "2023-10-14T20:11:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)\
**Post date:** [2023 年 10 月 14 日午後 8:11 UTC](https://forum.ficusonline.com/t/topic/496/1 "2023-10-14T20:11:43Z")

</div>

## [プログラミング言語 Rust](https://www.rust-lang.org/ja-JP/index.html)

[https://github.com/rust-lang/book](https://github.com/rust-lang/book)

### [The Rust Programming Language - The Rust Programming Language](https://doc.rust-lang.org/stable/book/)

ユーザ環境にインストール (Ubuntu 22.04)

```auto
$ curl --proto '=https' --tlsv1.2 https:/sh.rustup.rs -sSf | sh

```

アップデート

```auto
$ rustup update

```

アンインストール

```auto
$ rustup self uninstall

```

* * *

**`cargo`** : プロジェクト作成からビルド、起動まで

- create a project using **`cargo new`**.
- build a project using **`cargo build`**.
- build and run a project in one step using **`cargo run`**.
- 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.

```auto
$ cargo -h
Rust's package manager

Usage: cargo [+toolchain] [OPTIONS] [COMMAND]
       cargo [+toolchain] [OPTIONS] -Zscript <MANIFEST_RS> [ARGS]...

Options:
  -V, --version Print version info and exit
      --list List installed commands
      --explain <CODE> Run `rustc --explain CODE`
  -v, --verbose... Use verbose output (-vv very verbose/build.rs output)
  -q, --quiet Do not print cargo log messages
      --color <WHEN> Coloring: auto, always, never
  -C <DIRECTORY> Change to DIRECTORY before doing anything (nightly-only)
      --frozen Require Cargo.lock and cache are up to date
      --locked Require Cargo.lock is up to date
      --offline Run without accessing the network
      --config <KEY=VALUE> Override a configuration value
  -Z <FLAG> Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
  -h, --help Print help

Some common cargo commands are (see all commands with --list):
    build, b Compile the current package
    check, c Analyze the current package and report errors, but don't build object files
    clean Remove the target directory
    doc, d Build this package's and its dependencies' documentation
    new Create a new cargo package
    init Create a new cargo package in an existing directory
    add Add dependencies to a manifest file
    remove Remove dependencies from a manifest file
    run, r Run a binary or example of the local package
    test, t Run the tests
    bench Run the benchmarks
    update Update dependencies listed in Cargo.lock
    search Search registry for crates
    publish Package and upload this package to the registry
    install Install a Rust binary. Default location is $HOME/.cargo/bin
    uninstall Uninstall a Rust binary

```

作成したプロジェクトフォルダ内で `$ cargo -doc --open` コマンドを実行すると、依存関係のドキュメントがブラウザに表示されます。

* * *

### The Rust community’s crate registry

[https://crates.io/](https://crates.io/)
