关于软件篋项目hello-world

学习内容

  • 了解项目名称和目录
  • 了解项目目录和文件结构

篇目

  1. 项目名称清单
  2. 软件篋类型清单
  3. 项目目录清单
  4. 项目文件清单
  5. 项目结构树
  6. 题外话:目录与命令

项目名称清单

项目类型项目名称相对路径项目说明
作业区hello-world./hello-world开发共享软件篋工作区
共享篋lib-hello./hello-world/lib-hello开发共享软件篋实例
本地程序bin-local-hello./hello-world/bin-local-hello使用在本地的共享篋
仓库程序bin-hello./hello-world/bin-hello使用在crates.io上共享篋
共享篋lib-extern./hello-world/lib-extern作为第三方共享篋实例使用

软件篋类型清单

篋类型篋名称相对路径
共享软件篋hello_exercism./hello-world/lib-hello
可执行程序bin-local-hello./hello-world/bin-local-hello
可执行程序bin-hello./hello-world/bin-hello
共享软件篋hello_extern./hello-world/lib-extern

项目目录清单

目录名称根目录说明生成方式
src篋源代码目录Cargo命令
src/integration_tests篋源代码集成测试目录用户手动命令
src/private_tests篋源代码私有代码测试目录用户手动命令
tests篋测试源代码目录用户手动命令
examples篋实例源代码目录用户手动命令
target篋构建目录Cargo命令
debug篋调试构建目录Cargo命令
release篋版本构建目录Cargo命令

项目文件清单

名称说明内容属性名称属性
README.md项目说明文件可修改不可修改
Cargo.lock项目配置锁定文件不可修改不可修改
Cargo.toml项目配置锁定文件可修改不可修改
main.rs可执行软件篋的入口文件可修改不可修改
lib.rs共享软件篋的入口文件可修改不可修改
mod.rs篋模块的入口文件可修改不可修改
i_hello.rs集成测试或者实例文件可修改可修改
u_hello.rs单元测试或者实例文件可修改可修改
owned_hello.rs私有代码测试文件可修改可修改

项目结构树

── hello-world
    ├── Cargo.lock
    ├── Cargo.toml
    ├── README.md
    ├── bin-hello
    │   ├── Cargo.lock
    │   ├── Cargo.toml
    │   └── src
    │       └── main.rs
    ├── bin-local-hello
    │   ├── Cargo.lock
    │   ├── Cargo.toml
    │   ├── src
    │   │   └── main.rs
    │   └── tests
    │       └── i_hello.rs
    ├── lib-extern
    │   ├── Cargo.toml
    │   ├── README.md
    │   ├── src
    │   │   └── lib.rs
    │   └── tests
    │       └── u_hello.rs
    └── lib-hello
        ├── Cargo.toml
        ├── README.md
        ├── examples
        │   ├── i_hello.rs
        │   ├── main.rs
        │   └── u_hello.rs
        ├── src
        │   ├── integration_tests
        │   │   ├── i_hello.rs
        │   │   └── mod.rs
        │   ├── lib.rs
        │   └── private_tests
        │       ├── mod.rs
        │       └── owned_hello.rs
        └── tests
            ├── i_hello.rs
            └── u_hello.rs

题外话:目录与命令

目录名称生成命令删除命令
srccargo new <project_name>
cargo new <project_name> --lib
cargo new <project_name> --bin
cargo init --name <project_name>
cargo init --name <project_name> --bin
cargo init --name <project_name> --lib
用户手动命令
tests用户手动命令用户手动命令
examples用户手动命令用户手动命令
target随下面命令自动生成cargo clean
debugcargo build 或者 cargo runcargo clean --target-dir target/debug
releasecargo build --release
cargo run --release
cargo clean --release
cargo clean --target-dir target/release