AgentSkillsCN

cairo-generic-data-types

当请求涉及在 Cairo 中定义或调用函数、指定返回类型,或处理与函数相关的编译器错误时,讲解 Cairo 函数的语法、参数、返回值、语句与表达式,以及 `const fn` 的用法。

SKILL.md
--- frontmatter
name: cairo-generic-data-types
description: Explain Cairo generic data types and syntax for generic functions, structs, enums, methods, and impls; use when a request involves type parameters or generic signatures in Cairo.

Cairo Generic Data Types

Overview

Explain how to declare and use generic types and functions in Cairo with correct syntax.

Quick Use

  • Read references/generic-data-types.md before answering.
  • Show short examples for generic structs, enums, and functions.
  • Use explicit type annotations when inference is ambiguous.

Response Checklist

  • Place generic parameters after the item name: struct Name<T> or fn foo<T>().
  • Support multiple parameters: struct Pair<T, U>.
  • Emphasize that generics work with functions, structs, enums, traits, impls, and methods.

Example Requests

  • "How do I write a generic struct in Cairo?"
  • "Can I have multiple type parameters?"
  • "Why does the compiler need a type annotation for this generic?"

Cairo by Example