Rust 手習い
htmlファイルを入力に取ってtableをmarkdownに出力するツールをつくる
まっさらな環境から始めることを想定
前にもやったけど忘れたのでもう一度
まず rustup をインストールする
code:terminal
info: downloading installer
Welcome to Rust!
This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.
Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:
/Users/inutano/.rustup
This can be modified with the RUSTUP_HOME environment variable.
The Cargo home directory located at:
/Users/inutano/.cargo
This can be modified with the CARGO_HOME environment variable.
The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:
/Users/inutano/.cargo/bin
This path will then be added to your PATH environment variable by
modifying the profile files located at:
/Users/inutano/.profile
/Users/inutano/.zshenv
You can uninstall at any time with rustup self uninstall and
these changes will be reverted.
Current installation options:
default host triple: x86_64-apple-darwin
default toolchain: stable (default)
profile: default
modify PATH variable: yes
1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
1
...
Rust is installed now. Great!
To get started you may need to restart your current shell.
This would reload your PATH environment variable to include
Cargo's bin directory ($HOME/.cargo/bin).
To configure your current shell, run:
source $HOME/.cargo/env
$ rustup update
info: syncing channel updates for 'stable-x86_64-apple-darwin'
info: checking for self-updates
stable-x86_64-apple-darwin unchanged - rustc 1.55.0 (c8dfcfe04 2021-09-06)
info: cleaning up downloads & tmp directories
イエーイ
cargo でプロジェクトディレクトリを作る
code:terminal
$ cargo new htmltable-to-markdown
Created binary (application) htmltable-to-markdown package
$ cd htmltable-to-markdown
$ tree
.
├── Cargo.toml
└── src
└── main.rs
1 directory, 2 files
$ cargo run
Compiling htmltable-to-markdown v0.1.0 (/Users/inutano/repos/htmltable-to-markdown)
Running target/debug/htmltable-to-markdown
Hello, world!
ヨシ!
まずは htmlparse 部分