時間が取れたので久しぶりのRust開発の再開です。
4ヶ月ほど時間が経ってしまったので環境が多少古くなっているようです。新しい機能や修正を取り入れておきたいので、まずはツールチェインのアップデートから。
$ rustup --version
rustup 1.27.1 (54dd3d00f 2024-04-24)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.77.2 (25ef9e3d8 2024-04-09)`
$ rustup self update
info: checking for self-update
rustup unchanged - 1.27.1
ツールチェインは特にアップデートはなかったようです。
コンパイラは確実に上がっていると思いますのでアップデートします。
$ rustup show
Default host: x86_64-unknown-linux-gnu
rustup home: /home/xxxxx/.rustup
installed targets for active toolchain
--------------------------------------
x86_64-pc-windows-gnu
x86_64-unknown-linux-gnu
active toolchain
----------------
stable-x86_64-unknown-linux-gnu (default)
rustc 1.77.2 (25ef9e3d8 2024-04-09)
$ rustup update stable
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: latest update on 2024-09-05, rust version 1.81.0 (eeb90cda1 2024-09-04)
info: downloading component 'rust-src'
2.8 MiB / 2.8 MiB (100 %) 1.4 MiB/s in 2s ETA: 0s
info: downloading component 'rust-std' for 'x86_64-pc-windows-gnu'
22.8 MiB / 22.8 MiB (100 %) 1.4 MiB/s in 16s ETA: 0s
info: downloading component 'cargo'
8.3 MiB / 8.3 MiB (100 %) 1.5 MiB/s in 5s ETA: 0s
info: downloading component 'clippy'
2.6 MiB / 2.6 MiB (100 %) 1.5 MiB/s in 1s ETA: 0s
info: downloading component 'rust-docs'
15.9 MiB / 15.9 MiB (100 %) 1.4 MiB/s in 11s ETA: 0s
info: downloading component 'rust-std'
26.8 MiB / 26.8 MiB (100 %) 1.4 MiB/s in 19s ETA: 0s
info: downloading component 'rustc'
66.9 MiB / 66.9 MiB (100 %) 1.4 MiB/s in 47s ETA: 0s
info: downloading component 'rustfmt'
2.4 MiB / 2.4 MiB (100 %) 1.4 MiB/s in 1s ETA: 0s
info: removing previous version of component 'rust-src'
info: removing previous version of component 'rust-std' for 'x86_64-pc-windows-gnu'
info: removing previous version of component 'cargo'
info: removing previous version of component 'clippy'
info: removing previous version of component 'rust-docs'
info: removing previous version of component 'rust-std'
info: removing previous version of component 'rustc'
info: removing previous version of component 'rustfmt'
info: installing component 'rust-src'
info: installing component 'rust-std' for 'x86_64-pc-windows-gnu'
22.8 MiB / 22.8 MiB (100 %) 16.0 MiB/s in 1s ETA: 0s
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
15.9 MiB / 15.9 MiB (100 %) 5.7 MiB/s in 2s ETA: 0s
info: installing component 'rust-std'
26.8 MiB / 26.8 MiB (100 %) 15.8 MiB/s in 1s ETA: 0s
info: installing component 'rustc'
66.9 MiB / 66.9 MiB (100 %) 17.8 MiB/s in 3s ETA: 0s
info: installing component 'rustfmt'
stable-x86_64-unknown-linux-gnu updated - rustc 1.81.0 (eeb90cda1 2024-09-04) (from rustc 1.77.2 (25ef9e3d8 2024-04-09))
info: checking for self-update
$ rustup show
Default host: x86_64-unknown-linux-gnu
rustup home: /home/xxxxx/.rustup
installed targets for active toolchain
--------------------------------------
x86_64-pc-windows-gnu
x86_64-unknown-linux-gnu
active toolchain
----------------
stable-x86_64-unknown-linux-gnu (default)
rustc 1.81.0 (eeb90cda1 2024-09-04)
1.77.2から1.81.0になりました。clippyなど周辺のコンポーネントも新しくなったようです。
開発に使用しているcrossterm やratatui パッケージは両方とも0.28.1になっているようです。
これらもアップデートしてみます。
一応ドライランで実行してみます。
$ cargo update --dry-run
Updating crates.io index
Updating bitflags v2.5.0 -> v2.6.0
Updating castaway v0.2.2 -> v0.2.3
Updating either v1.12.0 -> v1.13.0
Updating heck v0.4.1 -> v0.5.0
Adding itertools v0.13.0
Updating libc v0.2.154 -> v0.2.158
Updating log v0.4.21 -> v0.4.22
Updating lru v0.12.3 -> v0.12.4
Updating parking_lot v0.12.2 -> v0.12.3
Updating proc-macro2 v1.0.84 -> v1.0.86
Updating quote v1.0.36 -> v1.0.37
Updating redox_syscall v0.5.1 -> v0.5.4
Updating signal-hook-mio v0.2.3 -> v0.2.4
Updating stability v0.2.0 -> v0.2.1
Updating strum v0.26.2 -> v0.26.3
Updating strum_macros v0.26.2 -> v0.26.4
Updating syn v2.0.66 -> v2.0.77
Updating unicode-ident v1.0.12 -> v1.0.13
Updating unicode-segmentation v1.11.0 -> v1.12.0
Updating unicode-truncate v1.0.0 -> v1.1.0
Updating unicode-width v0.1.12 -> v0.1.14
Updating version_check v0.9.4 -> v0.9.5
Updating windows-targets v0.52.5 -> v0.52.6
Updating windows_aarch64_gnullvm v0.52.5 -> v0.52.6
Updating windows_aarch64_msvc v0.52.5 -> v0.52.6
Updating windows_i686_gnu v0.52.5 -> v0.52.6
Updating windows_i686_gnullvm v0.52.5 -> v0.52.6
Updating windows_i686_msvc v0.52.5 -> v0.52.6
Updating windows_x86_64_gnu v0.52.5 -> v0.52.6
Updating windows_x86_64_gnullvm v0.52.5 -> v0.52.6
Updating windows_x86_64_msvc v0.52.5 -> v0.52.6
Updating zerocopy v0.7.34 -> v0.7.35
Updating zerocopy-derive v0.7.34 -> v0.7.35
warning: not updating lockfile due to dry run
どうやらcrossterm やratatui に依存しているパッケージはアップデートされるようですが自身はアップデートされないみたいです。
仕方ないのでCargo.tomlを直接編集しておきます。最後にcargo updateを実行しておきます。
[package]
name = "binllion"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
crossterm = "0.28.1"
ratatui = "0.28.1"
TOC
- 準備
- ターミナル入出力を試す
- ターミナル系crateを利用する
- 編集データと表示処理
- 画面制御
- その他
GitHubにコードをアップロードしています。
コードのコメントに書かれているfirst_stepなどをcargoコマンドに渡すと実行できます。
# Example
$ cargo run --examples first_step