No description
| src | ||
| .gitignore | ||
| Cargo.toml | ||
| LICENSE | ||
| README.md | ||
| rust-toolchain.toml | ||
Rust Template
A simple Hello World Rust template project with ISC license.
Description
This project serves as a basic template for Rust applications. It includes:
- A library crate (
lib.rs) with hello world functionality - A binary crate (
main.rs) that demonstrates library usage - Comprehensive tests
- ISC license
- Proper project structure
Features
hello_world()- Returns a basic "Hello, World!" greetinghello_name(name)- Returns a personalized greeting for a given name- Full documentation with examples
- Unit tests covering all functionality
Usage
As a Library
Add this to your Cargo.toml:
[dependencies]
rust-tpl = "0.1.0"
Then use it in your code:
use rust_tpl::{hello_world, hello_name};
fn main() {
println!("{}", hello_world());
println!("{}", hello_name("Alice"));
}
Running the Binary
cargo run
Running Tests
cargo test
Building
cargo build --release
Project Structure
rust-tpl/
├── .gitignore # Git ignore rules for Rust, editors, and OS
├── .vscode/ # VSCode configuration
│ ├── extensions.json # Recommended extensions
│ ├── launch.json # Debug configurations
│ ├── settings.json # Rust-specific settings
│ └── tasks.json # Build and test tasks
├── Cargo.toml # Project configuration
├── LICENSE # ISC license
├── README.md # This file
├── rust-toolchain.toml # Rust toolchain specification
└── src/
├── lib.rs # Library code with hello world functions
└── main.rs # Binary that uses the library
Documentation
Generate and view the documentation:
cargo doc --open
Development
The project includes configurations for popular editors:
- VSCode: Complete setup with rust-analyzer, debugging, tasks, and recommended extensions
- Rust Toolchain: Specified in
rust-toolchain.tomlfor consistent development environment - Git: Comprehensive
.gitignorefor Rust projects, editors (VSCode, Zed, Vim/Neovim), and OS files
Available VSCode Tasks
cargo build- Build the projectcargo build --release- Build optimized releasecargo test- Run all testscargo clippy- Run lintercargo fmt- Format codecargo doc- Generate documentationrust: full check- Run format, lint, and test in sequence
Debugging
Debug configurations are available for:
- Debug/release builds of the main binary
- Unit tests debugging
- Process attachment
License
This project is licensed under the ISC License. See the LICENSE file for details.
Editor Support
VSCode
Complete configuration included with:
- Rust Analyzer settings optimized for development
- Debug configurations for binary and tests
- Recommended extensions for Rust development
- Custom tasks for common cargo commands
Other Editors
The .gitignore file includes patterns for:
- Zed:
.zed/directory exclusions - Vim/Neovim: Swap files, session files, plugin directories
- JetBrains IDEs:
.idea/and related files - Sublime Text: Project and workspace files
Requirements
- Rust: 1.70.0 or later (specified in
rust-toolchain.toml) - Edition: 2021 (latest stable)
- MSRV: 1.70.0 (Minimum Supported Rust Version)
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Run
cargo testto ensure all tests pass - Submit a pull request
Template Usage
This project is designed to be used as a template for new Rust projects. You can:
- Clone or fork this repository
- Update the
Cargo.tomlwith your project details - Replace the hello world functionality with your own code
- Update this README with your project's information
- Update the LICENSE file with your copyright information