Template
1
0
Fork 0
No description
Find a file Use this template
2026-01-07 09:50:53 +01:00
src init: initial commit 2026-01-07 09:50:53 +01:00
.gitignore init: initial commit 2026-01-07 09:50:53 +01:00
Cargo.toml init: initial commit 2026-01-07 09:50:53 +01:00
LICENSE init: initial commit 2026-01-07 09:50:53 +01:00
README.md init: initial commit 2026-01-07 09:50:53 +01:00
rust-toolchain.toml init: initial commit 2026-01-07 09:50:53 +01:00

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!" greeting
  • hello_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.toml for consistent development environment
  • Git: Comprehensive .gitignore for Rust projects, editors (VSCode, Zed, Vim/Neovim), and OS files

Available VSCode Tasks

  • cargo build - Build the project
  • cargo build --release - Build optimized release
  • cargo test - Run all tests
  • cargo clippy - Run linter
  • cargo fmt - Format code
  • cargo doc - Generate documentation
  • rust: 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

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Run cargo test to ensure all tests pass
  6. Submit a pull request

Template Usage

This project is designed to be used as a template for new Rust projects. You can:

  1. Clone or fork this repository
  2. Update the Cargo.toml with your project details
  3. Replace the hello world functionality with your own code
  4. Update this README with your project's information
  5. Update the LICENSE file with your copyright information