Compare commits
5 Commits
main
..
dd91946fb2
| Author | SHA1 | Date | |
|---|---|---|---|
| dd91946fb2 | |||
| 0ed932a44a | |||
| 9eb53e2561 | |||
| 2cf2725df3 | |||
| 40aaaf4b49 |
+1
-18
@@ -1,18 +1 @@
|
||||
# ---> Rust
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
debug/
|
||||
target/
|
||||
|
||||
# These are backup files generated by rustfmt
|
||||
**/*.rs.bk
|
||||
|
||||
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||
*.pdb
|
||||
|
||||
# RustRover
|
||||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
||||
/target
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
# Agent Guidelines for opencode-testing
|
||||
|
||||
This is a Rust project using Edition 2024.
|
||||
|
||||
## Build/Test Commands
|
||||
|
||||
```bash
|
||||
# Build the project
|
||||
cargo build
|
||||
|
||||
# Build for release
|
||||
cargo build --release
|
||||
|
||||
# Run the application
|
||||
cargo run
|
||||
|
||||
# Run all tests
|
||||
cargo test
|
||||
|
||||
# Run a specific test (e.g., test named `test_calculate_area`)
|
||||
cargo test test_calculate_area
|
||||
|
||||
# Run tests in a specific module
|
||||
cargo test module_name::
|
||||
|
||||
# Run with output visible
|
||||
cargo test -- --nocapture
|
||||
|
||||
# Check for compilation errors without building
|
||||
cargo check
|
||||
|
||||
# Watch mode for development (requires cargo-watch)
|
||||
cargo watch -x "run"
|
||||
```
|
||||
|
||||
## Code Quality Commands
|
||||
|
||||
```bash
|
||||
# Format code (rustfmt)
|
||||
cargo fmt
|
||||
|
||||
# Check formatting without making changes
|
||||
cargo fmt -- --check
|
||||
|
||||
# Run clippy lints
|
||||
cargo clippy
|
||||
|
||||
# Run clippy with all features and warnings as errors
|
||||
cargo clippy --all-features -- -D warnings
|
||||
```
|
||||
|
||||
## Code Style Guidelines
|
||||
|
||||
### Formatting
|
||||
- Use `cargo fmt` with default settings
|
||||
- Max line width: 100 characters (default)
|
||||
- Use 4 spaces for indentation (default)
|
||||
- Trailing commas in multi-line lists
|
||||
|
||||
### Naming Conventions
|
||||
- Variables, functions, modules: `snake_case`
|
||||
- Types (structs, enums, traits): `CamelCase`
|
||||
- Constants, statics: `SCREAMING_SNAKE_CASE`
|
||||
- Lifetimes: `'lowercase`
|
||||
- Generic type parameters: `CamelCase` (single uppercase letter preferred: `T`, `K`, `V`)
|
||||
- Macros: `snake_case!`
|
||||
|
||||
### Import Organization
|
||||
Group imports in this order, separated by blank lines:
|
||||
1. Standard library imports (`std::`, `core::`, `alloc::`)
|
||||
2. External crate imports
|
||||
3. Internal crate imports (`crate::`)
|
||||
4. Super module imports (`super::`)
|
||||
5. Current module imports (`self::`)
|
||||
|
||||
Use `use` statements not `extern crate`.
|
||||
|
||||
### Types and Type Safety
|
||||
- Prefer explicit types over `impl Trait` in public APIs
|
||||
- Use `Option<T>` and `Result<T, E>` for fallible operations
|
||||
- Avoid `unwrap()` and `expect()` in production code; handle errors properly
|
||||
- Use `?` operator for error propagation
|
||||
- Prefer `&str` over `&String`, `&[T]` over `&Vec<T>` for function parameters
|
||||
|
||||
### Error Handling
|
||||
- Define custom error types using `thiserror` or `enum` for complex error cases
|
||||
- Use `anyhow` for application code error handling
|
||||
- Propagate errors with `?` operator
|
||||
- Provide context with `map_err()` when needed
|
||||
|
||||
### Functions
|
||||
- Keep functions small and focused on a single task
|
||||
- Max 5-7 parameters; use structs for more complex parameter sets
|
||||
- Document public functions with `///` doc comments
|
||||
- Use early returns to reduce nesting
|
||||
|
||||
### Comments and Documentation
|
||||
- Use `//` for inline comments
|
||||
- Use `///` for public API documentation
|
||||
- Use `//!` for module-level documentation
|
||||
- Document panics, unsafe code, and complex algorithms
|
||||
|
||||
### Unsafe Code
|
||||
- Avoid unsafe code unless absolutely necessary
|
||||
- Document all safety invariants with `// SAFETY:` comments
|
||||
- Keep unsafe blocks as small as possible
|
||||
|
||||
### Testing
|
||||
- Write unit tests in the same file as the code: `#[cfg(test)]` module
|
||||
- Use descriptive test names: `test_<scenario>_<expected_behavior>`
|
||||
- Use `assert!`, `assert_eq!`, `assert_ne!` for assertions
|
||||
- Organize tests with submodules for different scenarios
|
||||
|
||||
### Memory Management
|
||||
- Prefer ownership and borrowing over cloning when possible
|
||||
- Use `.clone()` explicitly when needed
|
||||
- Consider `Cow<'_, T>` for data that may be borrowed or owned
|
||||
|
||||
### Performance
|
||||
- Avoid premature optimization; write clear code first
|
||||
- Use iterators instead of loops when appropriate
|
||||
- Profile before optimizing
|
||||
Generated
+7
@@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "opencode-testing"
|
||||
version = "0.1.0"
|
||||
@@ -0,0 +1,9 @@
|
||||
[package]
|
||||
name = "opencode-testing"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.0.0", features = ["derive"] }
|
||||
serde = { version = "1.0.130", features = ["derive"] }
|
||||
serde_json = "1.0.130"
|
||||
@@ -1,18 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 jakob
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
associated documentation files (the "Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial
|
||||
portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
|
||||
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -1,3 +0,0 @@
|
||||
# Learn-Rust-through-projects
|
||||
|
||||
Example code from the book "Learn Rust through projects" by Julia Lornfield
|
||||
@@ -0,0 +1,6 @@
|
||||
use std::env;
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
println!("Arguments: {:?}", args);
|
||||
}
|
||||
Reference in New Issue
Block a user