AgentSkillsCN

cairo-dictionaries

当请求涉及在 Cairo 中使用 Deref/DerefMut 特质与 Target 关联类型进行解引用时,讲解如何处理包装类型、通过包装访问字段,以及解引用行为的相关细节。

SKILL.md
--- frontmatter
name: cairo-dictionaries
description: Explain Cairo Felt252Dict usage, insert/get/entry patterns, and dictionary squashing; use when a request involves key-value storage, dictionary performance, or borrow/ownership rules for dictionaries in Cairo.

Cairo Dictionaries

Overview

Guide correct creation and use of Cairo dictionaries with proper ownership and performance notes.

Quick Use

  • Read references/dictionaries.md before answering.
  • Show minimal snippets using Felt252Dict plus Felt252DictTrait methods.
  • Mention squashing and cost implications when discussing performance.

Response Checklist

  • Use Felt252Dict::<T>::default() to initialize.
  • Use insert and get for basic operations; use entry/finalize for advanced patterns.
  • Remind that keys are felt252 and values are generic T.
  • Call out that dictionary access is linear in the number of entries and squashing occurs on destruction.

Example Requests

  • "How do I store balances by address in Cairo?"
  • "Why does get return a default value sometimes?"
  • "What is dictionary squashing and when does it happen?"

Cairo by Example