The crate "hello_exercism"
I. develop the crate
Step 1: create the default crate
mkdir lib-hello && cd lib-hello
cargo init --name hello_exercism --lib
Step 2: develop the crate source and test codes
vi Cargo.toml
vi src/lib.rs
mkdir tests
touch tests/hello.rs
vi tests/hello.rs
cargo test
Step 3: develop the example codes
mkdir examples
touch examples/hello.rs
vi examples/hello.rs
cargo run --example hello
II. use the crate 'hello_exercism'
Step 1: create the default Bin
mkdir bin-hello && cd bin-hello
cargo init --name bin-hello --bin
Step 2: configure the file Cargo.toml
echo 'hello_exercism = "0.2.2"' >> Cargo.toml
Step 3: edit the rust file main.rs
use hello_exercism;
fn main () {
println!("{}",hello_exercism::hello());
assert_eq!("Hello, World!", hello_exercism::hello());
}
Step 4: run the Bin program
cargo run main
III. create the crate 'hello_exercism' doc in local version
cargo doc --open --package hello_exercism
IV. create the crate 'hello_exercism' doc in server version
- github.com >> >> Setting >> Options >> GitHub Pages >> ...
- Go to Crate Root Path
cargo doc
mkdir <REPOSITORY>/docs/<PROJECT_NAME>
cp -rf target/doc/*.* <REPOSITORY>/docs/<PROJECT_NAME>/.
- Example:
- Go to Crate Root Path
cargo doc
mkdir -p ../../docs/hello-world
cargo doc
cp -rf target/doc/*.* ../../docs/hello-world/