cangjie-struct

Explain Cangjie struct definitions, member variables, and mut functions.

1|Updated Mar 14, 2026
One-click install
npx skills add https://github.com/SunriseSummer/CangjieDocValidator --skill cangjie-struct
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cangjie-struct
Source: https://github.com/SunriseSummer/CangjieDocValidator/tree/main/.github/skills/struct
Command: npx skills add https://github.com/SunriseSummer/CangjieDocValidator --skill cangjie-struct

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers understand and correctly implement the intricate details of defining and using structures in the Cangjie programming language, ensuring robust data modeling and efficient code.

Core Features & Use Cases

  • Struct Definition: Learn the syntax for defining structs, including members, properties, and initializers.
  • Instance Creation & Modification: Understand how to create struct instances and modify their mutable members, respecting value semantics.
  • mut Functions: Grasp the concept and application of mut functions for in-place modification of struct instances, including their limitations and usage within interfaces.
  • Use Case: When building data-centric applications in Cangjie, you need to define custom data types. This Skill guides you through creating these types using structs, ensuring correct data encapsulation and manipulation.

Quick Start

Explain how to define a struct named 'Point' with 'x' and 'y' integer members and a 'distance' method.

Frequently Asked Questions about cangjie-struct

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I define and modify struct instances in Cangjie?

To define a struct in Cangjie, declare member variables and an initializer. You create and modify struct instances respecting value semantics, using `mut` functions for in-place member modification.

How do `mut` functions work for in-place struct modification in Cangjie?

`mut` functions in Cangjie enable in-place modification of struct instances. They have specific usage rules and limitations, particularly regarding their implementation and behavior within interfaces for value types.

Can I define recursive structs in Cangjie?

No, recursive structs are explicitly prohibited in Cangjie. This limitation prevents infinite size cycles during compilation, requiring alternative data modeling approaches for self-referential structures.

How do I add properties and static members to a Cangjie struct?

Cangjie structs support member variables, static members, properties, and access modifiers. You define these elements during struct creation to ensure correct data encapsulation and manipulation.

What is the best way to extend an existing struct in Cangjie?

Cangjie supports struct extensions, allowing you to add new member functions and properties to existing struct definitions. This approach helps organize data-centric applications without altering the original structure.