cangjie-struct

Explain Cangjie struct design with members, constructors, and mut functions.

4|1|Updated Mar 29, 2026
One-click install
npx skills add https://github.com/JunjieChen0/NJUST --skill cangjie-struct-junjiechen0
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cangjie-struct
Source: https://github.com/JunjieChen0/NJUST/tree/main/.njust-ai/skills/cangjie-struct
Command: npx skills add https://github.com/JunjieChen0/NJUST --skill cangjie-struct-junjiechen0

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers understand how to define and use struct types in the Cangjie language, including how to declare members, define constructors, and apply value semantics and mutability rules.

Core Features & Use Cases

  • Struct Definition: syntax for defining structs with members, static and instance components.
  • Constructors & Init: normal and main constructors, plus automatic init generation when appropriate.
  • Mut Functions & Access: how mut functions modify instances and the constraints around this.
  • Use cases: learning language features, building example structs like Rectangle, and validating mut semantics in your codebase.

Quick Start

Create a sample Rectangle struct in Cangjie and show how to use its mut function to modify width and height.

Frequently Asked Questions about cangjie-struct

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

FAQPage Schema
How do I define a struct with constructors in the Cangjie language?

To define a struct in the Cangjie language, you declare members and use normal or main constructors, relying on automatic init generation when appropriate to streamline setup.

How do mut functions modify struct instances in Cangjie?

Mut functions modify struct instances in Cangjie by directly changing member values like width and height, operating under specific constraints to ensure safe value semantics.

What are the value semantics and mutability rules for Cangjie structs?

Cangjie structs use value semantics, meaning instances are copied rather than referenced, and mut functions must adhere to specific constraints to safely modify these values.

What are the non-recursive constraints when using structs in Cangjie?

Non-recursive constraints in Cangjie structs prevent a struct from containing instances of itself, ensuring safe memory usage and avoiding infinite size definitions during compilation.

Can I use access modifiers with struct members in Cangjie?

Yes, you can apply access modifiers to struct members in Cangjie to control visibility, alongside defining static and instance components for organized data encapsulation.

Why does my Cangjie struct constructor fail when automatic init is expected?

Automatic init generation in Cangjie structs fails when explicit constructors conflict with the expected member initialization pattern, requiring you to manually define the constructor logic.