โ† Back to list
rustfs

m01-ownership

by rustfs

๐Ÿš€2.3x faster than MinIO for 4KB object payloads. RustFS is an open-source, S3-compatible high-performance object storage system supporting migration and coexistence with other S3-compatible platforms such as MinIO and Ceph.

โญ 20,125๐Ÿด 866๐Ÿ“… Jan 23, 2026

SKILL.md


name: m01-ownership description: "CRITICAL: Use for ownership/borrow/lifetime issues. Triggers: E0382, E0597, E0506, E0507, E0515, E0716, E0106, value moved, borrowed value does not live long enough, cannot move out of, use of moved value, ownership, borrow, lifetime, 'a, 'static, move, clone, Copy, ๆ‰€ๆœ‰ๆƒ, ๅ€Ÿ็”จ, ็”Ÿๅ‘ฝๅ‘จๆœŸ"

Ownership & Lifetimes

Layer 1: Language Mechanics

Core Question

Who should own this data, and for how long?

Before fixing ownership errors, understand the data's role:

  • Is it shared or exclusive?
  • Is it short-lived or long-lived?
  • Is it transformed or just read?

Error โ†’ Design Question

ErrorDon't Just SayAsk Instead
E0382"Clone it"Who should own this data?
E0597"Extend lifetime"Is the scope boundary correct?
E0506"End borrow first"Should mutation happen elsewhere?
E0507"Clone before move"Why are we moving from a reference?
E0515"Return owned"Should caller own the data?
E0716"Bind to variable"Why is this temporary?
E0106"Add 'a"What is the actual lifetime relationship?

Thinking Prompt

Before fixing an ownership error, ask:

  1. What is this data's domain role?

    • Entity (unique identity) โ†’ owned
    • Value Object (interchangeable) โ†’ clone/copy OK
    • Temporary (computation result) โ†’ maybe restructure
  2. Is the ownership design intentional?

    • By design โ†’ work within constraints
    • Accidental โ†’ consider redesign
  3. Fix symptom or redesign?

    • If Strike 3 (3rd attempt) โ†’ escalate to Layer 2

Trace Up โ†‘

When errors persist, trace to design layer:

E0382 (moved value)
    โ†‘ Ask: What design choice led to this ownership pattern?
    โ†‘ Check: m09-domain (is this Entity or Value Object?)
    โ†‘ Check: domain-* (what constraints apply?)
Persistent ErrorTrace ToQuestion
E0382 repeatedm02-resourceShould use Arc/Rc for sharing?
E0597 repeatedm09-domainIs scope boundary at right place?
E0506/E0507m03-mutabilityShould use interior mutability?

Trace Down โ†“

From design decisions to implementation:

"Data needs to be shared immutably"
    โ†“ Use: Arc<T> (multi-thread) or Rc<T> (single-thread)

"Data needs exclusive ownership"
    โ†“ Use: move semantics, take ownership

"Data is read-only view"
    โ†“ Use: &T (immutable borrow)

Quick Reference

PatternOwnershipCostUse When
MoveTransferZeroCaller doesn't need data
&TBorrowZeroRead-only access
&mut TExclusive borrowZeroNeed to modify
clone()DuplicateAlloc + copyActually need a copy
Rc<T>Shared (single)Ref countSingle-thread sharing
Arc<T>Shared (multi)Atomic ref countMulti-thread sharing
Cow<T>Clone-on-writeAlloc if mutatedMight modify

Error Code Reference

ErrorCauseQuick Fix
E0382Value movedClone, reference, or redesign ownership
E0597Reference outlives ownerExtend owner scope or restructure
E0506Assign while borrowedEnd borrow before mutation
E0507Move out of borrowedClone or use reference
E0515Return local referenceReturn owned value
E0716Temporary droppedBind to variable
E0106Missing lifetimeAdd 'a annotation

Anti-Patterns

Anti-PatternWhy BadBetter
.clone() everywhereHides design issuesDesign ownership properly
Fight borrow checkerIncreases complexityWork with the compiler
'static for everythingRestricts flexibilityUse appropriate lifetimes
Leak with Box::leakMemory leakProper lifetime design

WhenSee
Need smart pointersm02-resource
Need interior mutabilitym03-mutability
Data is domain entitym09-domain
Learning ownership conceptsm14-mental-model

Score

Total Score

90/100

Based on repository quality metrics

โœ“SKILL.md

SKILL.mdใƒ•ใ‚กใ‚คใƒซใŒๅซใพใ‚Œใฆใ„ใ‚‹

+20
โœ“LICENSE

ใƒฉใ‚คใ‚ปใƒณใ‚นใŒ่จญๅฎšใ•ใ‚Œใฆใ„ใ‚‹

+10
โœ“่ชฌๆ˜Žๆ–‡

100ๆ–‡ๅญ—ไปฅไธŠใฎ่ชฌๆ˜ŽใŒใ‚ใ‚‹

+10
โœ“ไบบๆฐ—

GitHub Stars 1000ไปฅไธŠ

+15
โœ“ๆœ€่ฟ‘ใฎๆดปๅ‹•

1ใƒถๆœˆไปฅๅ†…ใซๆ›ดๆ–ฐ

+10
โœ“ใƒ•ใ‚ฉใƒผใ‚ฏ

10ๅ›žไปฅไธŠใƒ•ใ‚ฉใƒผใ‚ฏใ•ใ‚Œใฆใ„ใ‚‹

+5
โ—‹Issue็ฎก็†

ใ‚ชใƒผใƒ—ใƒณIssueใŒ50ๆœชๆบ€

0/5
โœ“่จ€่ชž

ใƒ—ใƒญใ‚ฐใƒฉใƒŸใƒณใ‚ฐ่จ€่ชžใŒ่จญๅฎšใ•ใ‚Œใฆใ„ใ‚‹

+5
โœ“ใ‚ฟใ‚ฐ

1ใคไปฅไธŠใฎใ‚ฟใ‚ฐใŒ่จญๅฎšใ•ใ‚Œใฆใ„ใ‚‹

+5

Reviews

๐Ÿ’ฌ

Reviews coming soon