UI はローカライズ済みです。スキルの紹介と説明文書は選択した言語へ AI が自動翻訳し、コード・コマンド・パス・専門用語は原文のままです。原作者の文書が優先されます。
スキルを探す
開発・技術 · SKILL.md

rust-skills-software-engineering

rust-skills-software-engineering

Implements software engineering skills for Rust programming, covering key aspects including the ownership model, async/await, Cargo package manager, and unsafe code practices. Each section provides guidance, examples, and constraints for using these features effectively.

Independent GitHub snapshot · Automated classification · Original documentation governs

スキルの説明

GitHub

name: rust-skills-software-engineering

description: Implements software engineering skills for Rust programming, covering key aspects including the ownership model, async/await, Cargo package manager, and unsafe code practices. Each section provides guidance, examples, and constraints for using these features effectively. license: MIT compatibility: opencode metadata: archetypes: implementation, reference anti_triggers: documentation, tutorial response_profile: verbosity: medium directive_strength: high abstraction_level: operational

version: "1.0.0" domain: coding triggers: rust, ownership model, async/await, cargo, unsafe code, memory safety role: implementation scope: implementation output-format: code related-skills: coding/rust/ownership-model, coding/rust/async-await, coding/rust/cargo, coding/rust/unsafe-code


Rust Skills for Software Engineering

Implements software engineering skills for Rust programming, covering key aspects including the ownership model, async/await, Cargo package manager, and unsafe code practices. Each section provides guidance, examples, and constraints for using these features effectively.

TL;DR Checklist

  • Understand Rust's ownership model and how it ensures memory safety.
  • Utilize async/await for writing non-blocking code.
  • Use Cargo for package management and dependency resolution.
  • Recognize when to apply unsafe code and avoid pitfalls.

When to Use

  • When building safe and efficient applications in Rust.
  • To implement concurrent programming patterns using async/await.
  • For managing dependencies and building projects using Cargo.
  • To understand and utilize unsafe code when necessary for performance.

When NOT to Use

  • Avoid unsafe code unless absolutely necessary; prefer safe Rust practices.
  • Do not use async/await in synchronous contexts.

Core Workflow

  1. Ownership Model — Understand how ownership, borrowing, and lifetimes work in Rust. Use Rust's compiler to enforce these rules.
  2. Async/Await — Implement asynchronous functions to leverage concurrent programming in I/O-bound applications. Use tokio or async-std as a runtime.
  3. Cargo — Create and manage your Rust projects using Cargo, ensuring all dependencies are declared in Cargo.toml.
  4. Unsafe Code — Identify scenarios where unsafe code is necessary; encapsulate it within safe abstractions.

Implementation Patterns

Pattern 1: Ownership Model

fn main() {
    let s1 = String::from("Hello");
    let s2 = s1; // Ownership is moved, s1 is no longer valid
    println!("{}", s2); // This is valid
}

Pattern 2: Async/Await

#[tokio::main]
async fn main() {
    let response = fetch_data().await;
    println!("Response: {}", response);
}

async fn fetch_data() -> String {
    // Perform async operation
    "data".to_string()
}

Pattern 3: Using Cargo

# Create a new Rust project using Cargo
cargo new my_project
# Build the project
cd my_project && cargo build
# Add dependencies in Cargo.toml

Pattern 4: Unsafe Code

unsafe {
    // Unsafe operations that bypass Rust's safety guarantees
}

Constraints

MUST DO

  • Use the ownership model to manage memory safety and prevent data races.
  • Use Rust’s type system to enforce correctness at compile time.

MUST NOT DO

  • Avoid memory leaks by adhering to the ownership model; do not create dangling references.
  • Do not overuse unsafe code; it should be a last resort for efficiency.

Related Skills

SkillPurpose
coding/rust/ownership-modelA focused skill on Rust’s ownership model
coding/rust/async-awaitA focused skill on asynchronous programming in Rust
coding/rust/cargoA focused skill on using Cargo for Rust package management
coding/rust/unsafe-codeA focused skill on Rust's unsafe code practices

Live References

Authoritative documentation links for this domain. The model follows markdown links at load time to resolve external references and inline content.

保存したスキル