Crates.io | hello_exercism |
lib.rs | hello_exercism |
version | 0.5.5 |
source | src |
created_at | 2019-09-21 10:43:03.402327 |
updated_at | 2019-10-07 05:52:38.862546 |
description | how to create an own crate |
homepage | https://crates.io/crates/hello_exercism |
repository | https://github.com/cnruby/learn-rust-by-crates/tree/master/hello-world |
max_upload_size | |
id | 166458 |
size | 101,686 |
hello_exercism
# create a workspaces
mkdir workpsaces && cd workpsaces
# create a workspace 'hello-world'
mkdir hello-world && cd hello-world
# create a configration for the workspace
touch Cargo.toml
# four crates for this workspace
# the follow lines is ONE command
echo '[workspace]
members = ["lib-hello", "bin-hello", "bin-local-hello", "lib-extern"]' >> Cargo.toml
mkdir lib-hello && cd lib-hello
# this is Crate Root Path
cargo init --name hello_exercism --lib
vi Cargo.toml
vi src/lib.rs
mkdir tests
touch tests/u_hello.rs
vi tests/u_hello.rs
touch tests/i_hello.rs
vi tests/i_hello.rs
cargo test
mkdir examples
touch examples/u_hello.rs
vi examples/u_hello.rs
cargo run --example u_hello
touch examples/i_hello.rs
vi examples/i_hello.rs
cargo run --example i_hello
vi src/lib.rs
mkdir -p src/integration_tests
touch src/integration_tests/mod.rs
vi src/integration_tests/mod.rs
touch src/integration_tests/i_hello.rs
vi src/integration_tests/i_hello.rs
mkdir -p src/private_tests
touch src/private_tests/mod.rs
vi src/private_tests/mod.rs
touch src/private_tests/owned_hello.rs
vi src/private_tests/owned_hello.rs
cargo test
## run the follow commant at A time
cargo login <token>
## can repeat the follow commands
cargo test
## commit and push the codes in github.com
cargo package
cargo publish
## change the release github.com
mkdir bin-hello && cd bin-hello
# this is Bin Root Path
cargo init --name bin-hello --bin
echo 'hello_exercism = "0.4.0"' >> Cargo.toml
// vi src/main.rs
use hello_exercism;
fn main () {
println!("{}",hello_exercism::hello());
assert_eq!("Hello, World!", hello_exercism::hello());
}
cargo run main
cargo doc --open --package hello_exercism
mkdir <REPOSITORY>/docs/<PROJECT_NAME>
cargo doc
cp -rf target/doc/. <REPOSITORY>/docs/<PROJECT_NAME>/.
mkdir -p ../../docs/hello-world
cargo doc
cp -rf target/doc/. ../../docs/hello-world/