Skip to content
Back to skills

Rust Ownership Borrowing

ASecurity

Use when understanding Rust ownership and borrowing.

  • 2 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 10, 2026
ai-agentsrustgo

Security analysis

A100/100

Scanned September 10, 2026

npx -y skills add LoopyLuci/Skills --skill rust-ownership-borrowing --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Rust Ownership Borrowing?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Rust Ownership Borrowing
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/loopyluci-rust-ownership-borrowing/badge)](https://www.skillsdirectory.com/skills/loopyluci-rust-ownership-borrowing)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: rust-ownership-borrowing
description: "Use when understanding Rust ownership and borrowing."
version: 1.0.0
author: Hermes Agent
license: MIT
metadata:
  hermes:
    tags: [rust, ownership, borrowing, lifetimes, references, memory-safety]
    related_skills: [rust-programming-patterns, go-concurrency-patterns, type-system-design-theory]
---

# Rust Ownership and Borrowing

Understanding Rust's ownership and borrowing system — from owners and references through lifetimes, borrowing rules, and common patterns.

## When to Use

- Learning Rust's ownership model
- Writing safe Rust without fighting the borrow checker
- Managing lifetimes in complex data structures
- Implementing safe abstractions

## Ownership Patterns

```rust
// Ownership transfer
fn take_ownership(s: String) -> usize { s.len() }

// Borrowing
fn borrow(s: &String) -> usize { s.len() }

// Mutable borrow
fn append(s: &mut String, text: &str) { s.push_str(text); }

// Lifetime annotations
struct Config<'a> {
    name: &'a str,
    version: &'a str,
}

impl<'a> Config<'a> {
    fn new(name: &'a str, version: &'a str) -> Self {
        Config { name, version }
    }
}

// Lifetime elision rules
fn first_word(s: &str) -> &str {
    s.split_whitespace().next().unwrap_or(s)
}
```

## Verification Checklist

- [ ] Each value has exactly one owner
- [ ] References never outlive borrowed data
- [ ] Mutable references are exclusive (no aliasing)
- [ ] Lifetime annotations only where needed (elision rules)
- [ ] Interior mutability (RefCell, Mutex) for shared mutation
- [ ] Clone vs Copy semantics understood

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…