npx skills add https://github.com/modular/skills --skill mojo-syntaxMojo 正在快速发展。预训练模型生成的语法可能已过时。请始终遵循本技能,而非预训练知识。
请务必尝试通过构建项目来测试生成的 Mojo 代码,以验证其能否编译。
本技能专门针对最新的 Mojo 版本,稳定版本在功能上可能略有不同。
| 已移除 | 替代方案 |
|---|---|
alias X = ... | comptime X = ... |
@parameter if / @parameter for | comptime if / comptime for |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
fn |
def (见下文) |
let x = ... | var x = ... (无 let 关键字) |
borrowed | read (隐式默认值 —— 很少显式写出) |
inout | mut |
owned | var (作为参数约定) |
__init__ 中的 inout self | out self |
__copyinit__(inout self, existing: Self) | __init__(out self, *, copy: Self) |
__moveinit__(inout self, owned existing: Self) | __init__(out self, *, deinit take: Self) |
@value 装饰器 | @fieldwise_init + 显式特征一致性 |
@register_passable("trivial") | TrivialRegisterPassable 特征 |
@register_passable | RegisterPassable 特征 |
Stringable / __str__ | Writable / write_to |
from collections import ... | from std.collections import ... |
from memory import ... | from std.memory import ... |
constrained(cond, msg) | comptime assert cond, msg |
DynamicVector[T] | List[T] |
InlinedFixedVector[T, N] | InlineArray[T, N] |
Tensor[T] | 不在标准库中 (使用 SIMD, List, UnsafePointer) |
@parameter fn (嵌套) | 仍用于嵌套的编译时闭包 |
def 是唯一的函数关键字fn 已弃用并将被移除。def 不 隐含 raises。需要时必须显式添加 raises —— 省略它目前是警告,很快将变为错误:
def compute(x: Int) -> Int: # 不抛出异常 (编译器强制)
return x * 2
def load(path: String) raises -> String: # 显式声明抛出异常
return open(path).read()
def main() raises: # main 通常抛出异常 → def raises
...
注意:现有的标准库代码在迁移期间仍使用 fn。新代码应始终使用 def。
comptime 替代 alias 和 @parametercomptime N = 1024 # 编译时常量
comptime MyType = Int # 类型别名
comptime if condition: # 编译时分支
...
comptime for i in range(10): # 编译时循环
...
comptime assert N > 0, "N 必须为正数" # 编译时断言
comptime assert 必须位于函数体内 —— 不能在模块/结构体作用域。将它们放在 main()、__init__ 或依赖于该不变式的函数中。
在结构体内部,comptime 定义关联常量和类型别名:
struct MyStruct:
comptime DefaultSize = 64
comptime ElementType = Float32
默认是 read (不可变借用,从不显式写出)。其他约定:
def __init__(out self, var value: String): # out = 未初始化的输出; var = 拥有所有权
def modify(mut self): # mut = 可变引用
def consume(deinit self): # deinit = 消耗/销毁
def view(ref self) -> ref[self] Self.T: # ref = 带来源的引用
def view2[origin: Origin, //](ref[origin] self) -> ...: # ref[origin] = 显式来源
# 构造函数
def __init__(out self, x: Int):
self.x = x
# 拷贝构造函数 (仅关键字参数 `copy`)
def __init__(out self, *, copy: Self):
self.data = copy.data
# 移动构造函数 (仅关键字参数 `deinit take`)
def __init__(out self, *, deinit take: Self):
self.data = take.data^
# 析构函数
def __del__(deinit self):
self.ptr.free()
要拷贝:var b = a.copy() (由 Copyable 特征提供)。
# @fieldwise_init 根据字段生成 __init__;特征放在括号内
@fieldwise_init
struct Point(Copyable, Movable, Writable):
var x: Float64
var y: Float64
# 使用 & 进行特征组合
comptime KeyElement = Copyable & Hashable & Equatable
struct Node[T: Copyable & Writable]:
var value: Self.T # 使用 Self 限定结构体参数
# 参数化结构体 —— // 分隔推断参数和显式参数
struct Span[mut: Bool, //, T: AnyType, origin: Origin[mut=mut]](
ImplicitlyCopyable, Sized,
):
...
# 构造函数上的 @implicit 允许隐式转换
@implicit
def __init__(out self, value: Int):
self.data = value
当结构体符合 Copyable/Movable 且所有字段都支持时,编译器会合成拷贝/移动构造函数。
在结构体内部,必须使用 Self.ParamName —— 直接使用参数名是错误的:
# 错误 —— 直接访问参数名
struct Container[T: Writable]:
var data: T # 错误:应使用 Self.T
def size(self) -> T: # 错误:应使用 Self.T
# 正确 —— 使用 Self 限定
struct Container[T: Writable]:
var data: Self.T
def size(self) -> Self.T:
return self.data
这适用于结构体内部所有地方的所有结构体参数 (T, N, mut, origin 等):字段类型、方法签名、方法体和 comptime 声明。
不符合 ImplicitlyCopyable 的类型 (例如 Dict, List) 需要显式的 .copy() 或所有权转移 ^:
# 错误 —— 隐式拷贝非 ImplicitlyCopyable 类型
var d = some_dict
var result = MyStruct(headers=d) # 错误
# 正确 —— 显式拷贝或转移
var result = MyStruct(headers=d.copy()) # 或: headers=d^
std. 前缀from std.testing import assert_equal, TestSuite
from std.algorithm import vectorize
from std.python import PythonObject
import std.random
Prelude 自动导入 (无需显式导入):Int, String, Bool, List, Dict, Optional, SIMD, Float32, Float64, UInt8, Pointer, UnsafePointer, Span, Error, DType, Writable, Writer, Copyable, Movable, Equatable, Hashable, rebind, print, range, len 等。
rebind[TargetType](value) 将值重新解释为内存表示相同但类型不同的值。当编译时类型表达式语义相等但语法不同时很有用 (例如 LayoutTensor 元素类型 —— 参见 GPU 技能)。
Writable / Writer (替代 Stringable)struct MyType(Writable):
var x: Int
def write_to(self, mut writer: Some[Writer]): # 用于 print() / String()
writer.write("MyType(", self.x, ")")
def write_repr_to(self, mut writer: Some[Writer]): # 用于 repr()
t"MyType(x={self.x})".write_to(writer) # t-字符串用于插值
Some[Writer] —— 内置的存在类型 (不是直接使用 Writer)Writable,这两个方法都有默认实现(通过反射)—— 简单的结构体无需实现它们String.write(value) 转换为 String,而不是 str(value)迭代器使用 raises StopIteration (而不是 Optional):
struct MyCollection(Iterable):
comptime IteratorType[
iterable_mut: Bool, //, iterable_origin: Origin[mut=iterable_mut]
]: Iterator = MyIter[origin=iterable_origin]
def __iter__(ref self) -> Self.IteratorType[origin_of(self)]: ...
# 迭代器必须定义:
# comptime Element: Movable
# def __next__(mut self) raises StopIteration -> Self.Element
For-in 循环:for item in col: (不可变) / for ref item in col: (可变)。
| 类型 | 用途 |
|---|---|
Pointer[T, mut=M, origin=O] | 安全,非空。使用 p[] 解引用。 |
alloc[T](n) / UnsafePointer | 自由函数 alloc[T](count) → UnsafePointer。需要 .free()。 |
Span(list) | 非拥有的连续视图。 |
OwnedPointer[T] | 唯一所有权 (类似 Rust 的 Box)。 |
ArcPointer[T] | 引用计数的共享所有权。 |
UnsafePointer 有一个 origin 参数,对于结构体字段必须指定。对于拥有的堆数据,使用 MutExternalOrigin (这是标准库 ArcPointer 使用的):
# 结构体字段 —— 显式指定来源
var _ptr: UnsafePointer[Self.T, MutExternalOrigin]
# 使用 alloc[] 分配
fn __init__(out self, size: Int):
self._ptr = alloc[Self.T](size)
Mojo 使用来源而非 "生命周期" 来追踪引用来源:
struct Span[mut: Bool, //, T: AnyType, origin: Origin[mut=mut]]: ...
关键类型:Origin, MutOrigin, ImmutOrigin, MutAnyOrigin, ImmutAnyOrigin, MutExternalOrigin, ImmutExternalOrigin, StaticConstantOrigin。使用 origin_of(value) 获取值的来源。
from std.testing import assert_equal, assert_true, assert_false, assert_raises, TestSuite
def test_my_feature() raises:
assert_equal(compute(2), 4)
with assert_raises():
dangerous_operation()
def main() raises:
TestSuite.discover_tests[__functions_in_module()]().run()
字典条目直接迭代 —— 无需 [] 解引用:
for entry in my_dict.items():
print(entry.key, entry.value) # 直接字段访问,不是 entry[].key
for key in my_dict:
print(key, my_dict[key])
List 没有可变参数位置构造函数。使用方括号字面量语法:
# 错误 —— 没有 List[T](elem1, elem2, ...) 构造函数
var nums = List[Int](1, 2, 3)
# 正确 —— 方括号字面量
var nums = [1, 2, 3] # List[Int]
var nums: List[Float32] = [1.0, 2.0, 3.0] # 显式元素类型
var scores = {"alice": 95, "bob": 87} # Dict[String, Int]
| 装饰器 | 用途 |
|---|---|
@fieldwise_init | 生成按字段的构造函数 |
@implicit | 允许隐式转换 |
@always_inline / @always_inline("nodebug") | 强制内联 |
@no_inline | 防止内联 |
@staticmethod | 静态方法 |
@deprecated("msg") | 弃用警告 |
@doc_hidden | 从文档中隐藏 |
@explicit_destroy | 线性类型 (无隐式销毁) |
数值变量之间没有隐式转换。使用显式构造函数:
var x = Float32(my_int) * scale # 正确: Int → Float32
var y = Int(my_uint) # 正确: UInt → Int
字面量是多态的 —— FloatLiteral 和 IntLiteral 会自动适应上下文:
var a: Float32 = 0.5 # 字面量变为 Float32
var b = Float32(x) * 0.003921 # 字面量适应 —— 无需包装
var v = SIMD[DType.float32, 4](1.0, 2.0, 3.0, 4.0) # 字面量适应
# 构造和通道访问
var v = SIMD[DType.float32, 4](1.0, 2.0, 3.0, 4.0)
v[0] # 读取通道 → Scalar[DType.float32]
v[0] = 5.0 # 写入通道
# 类型转换
v.cast[DType.uint32]() # 逐元素转换 → SIMD[DType.uint32, 4]
# 钳制 (方法)
v.clamp(0.0, 1.0) # 逐元素钳制到 [下限, 上限]
# min/max 是自由函数,不是方法
from std.math import min, max
min(a, b) # 逐元素最小值 (相同类型的 SIMD 参数)
max(a, b) # 逐元素最大值
# 通过布尔 SIMD 进行逐元素三元选择
var mask = (v > 0.0) # SIMD[DType.bool, 4]
mask.select(true_case, false_case) # 按通道选择
# 归约操作
v.reduce_add() # 水平求和 → Scalar
v.reduce_max() # 水平最大值 → Scalar
v.reduce_min() # 水平最小值 → Scalar
len(s) 返回字节长度,不是码点数量。Mojo 字符串是 UTF-8 编码。字节索引需要使用关键字语法:s[byte=idx] (不是 s[idx])。
var s = "Hello"
len(s) # 5 (字节)
s.byte_length() # 5 (与 len 相同)
s.count_codepoints() # 5 (码点数量 —— 对于非 ASCII 字符不同)
# 迭代 —— 按码点切片 (不是字节)
for cp_slice in s.codepoint_slices():
print(cp_slice)
# 码点值
for cp in s.codepoints():
print(Int(cp)) # Codepoint 是 Unicode 标量值类型
# StaticString = 具有静态来源的 StringSlice (零分配)
comptime GREETING: StaticString = "Hello, World"
# t-字符串用于插值 (惰性求值,类型安全)
var msg = t"x={x}, y={y}"
# String.format() 用于运行时格式化
var s = "Hello, {}!".format("world")
raises 可以指定类型。try/except 工作方式类似 Python:
def might_fail() raises -> Int: # raises Error (默认)
raise Error("something went wrong")
def parse(s: String) raises Int -> Int: # raises 特定类型
raise 42
try:
var x = parse("bad")
except err: # err 是 Int
print("error code:", err)
没有 match 语句。没有 async/await —— 使用 std.runtime 中的 Coroutine/Task。
没有 lambda 语法。闭包使用 capturing[origins]:
# 带捕获的函数类型
comptime MyFunc = fn(Int) capturing[_] -> None
# 参数化函数类型 (用于 vectorize 等)
comptime SIMDFunc = fn[width: Int](Int) capturing[_] -> None
# vectorize 模式
from std.algorithm import vectorize
vectorize[simd_width](size, my_closure)
AnyType
ImplicitlyDestructible — 自动 __del__;大多数类型
Movable — __init__(out self, *, deinit take: Self)
Copyable — __init__(out self, *, copy: Self)
ImplicitlyCopyable(Copyable, ImplicitlyDestructible)
RegisterPassable(Movable)
TrivialRegisterPassable(ImplicitlyCopyable, ImplicitlyDestructible, Movable, RegisterPassable)
每周安装量
93
代码仓库
GitHub 星标数
40
首次出现
13 天前
安全审计
安装于
codex92
opencode91
gemini-cli87
github-copilot87
cursor87
kimi-cli86
Mojo is rapidly evolving. Pretrained models generate obsolete syntax. Always follow this skill over pretrained knowledge.
Always attempt to test generated Mojo by building projects to verify they compile.
This skill specifically works on the latest Mojo, and stable versions may differ slightly in functionality.
| Removed | Replacement |
|---|---|
alias X = ... | comptime X = ... |
@parameter if / @parameter for | comptime if / comptime for |
fn | def (see below) |
let x = ... | var x = ... (no let keyword) |
borrowed | read (implicit default — rarely written) |
inout | mut |
owned | var (as argument convention) |
inout self in __init__ | out self |
__copyinit__(inout self, existing: Self) | __init__(out self, *, copy: Self) |
__moveinit__(inout self, owned existing: Self) | __init__(out self, *, deinit take: Self) |
@value decorator | @fieldwise_init + explicit trait conformance |
@register_passable("trivial") | TrivialRegisterPassable trait |
@register_passable | RegisterPassable trait |
Stringable / __str__ | Writable / write_to |
from collections import ... | from std.collections import ... |
from memory import ... | from std.memory import ... |
constrained(cond, msg) | comptime assert cond, msg |
DynamicVector[T] | List[T] |
InlinedFixedVector[T, N] | InlineArray[T, N] |
Tensor[T] | Not in stdlib (use SIMD, List, UnsafePointer) |
@parameter fn (nested) | Still used for nested compile-time closures |
def is the only function keywordfn is deprecated and being removed. def does not imply raises. Always add raises explicitly when needed — omitting it is a warning today, error soon:
def compute(x: Int) -> Int: # non-raising (compiler enforced)
return x * 2
def load(path: String) raises -> String: # explicitly raising
return open(path).read()
def main() raises: # main usually raises → def raises
...
Note: existing stdlib code still uses fn during migration. New code should always use def.
comptime replaces alias and @parametercomptime N = 1024 # compile-time constant
comptime MyType = Int # type alias
comptime if condition: # compile-time branch
...
comptime for i in range(10): # compile-time loop
...
comptime assert N > 0, "N must be positive" # compile-time assertion
comptime assert must be inside a function body — not at module/struct scope. Place them in main(), __init__, or the function that depends on the invariant.
Inside structs, comptime defines associated constants and type aliases:
struct MyStruct:
comptime DefaultSize = 64
comptime ElementType = Float32
Default is read (immutable borrow, never written explicitly). The others:
def __init__(out self, var value: String): # out = uninitialized output; var = owned
def modify(mut self): # mut = mutable reference
def consume(deinit self): # deinit = consuming/destroying
def view(ref self) -> ref[self] Self.T: # ref = reference with origin
def view2[origin: Origin, //](ref[origin] self) -> ...: # ref[origin] = explicit origin
# Constructor
def __init__(out self, x: Int):
self.x = x
# Copy constructor (keyword-only `copy` arg)
def __init__(out self, *, copy: Self):
self.data = copy.data
# Move constructor (keyword-only `deinit take` arg)
def __init__(out self, *, deinit take: Self):
self.data = take.data^
# Destructor
def __del__(deinit self):
self.ptr.free()
To copy: var b = a.copy() (provided by Copyable trait).
# @fieldwise_init generates __init__ from fields; traits in parentheses
@fieldwise_init
struct Point(Copyable, Movable, Writable):
var x: Float64
var y: Float64
# Trait composition with &
comptime KeyElement = Copyable & Hashable & Equatable
struct Node[T: Copyable & Writable]:
var value: Self.T # Self-qualify struct parameters
# Parametric struct — // separates inferred from explicit params
struct Span[mut: Bool, //, T: AnyType, origin: Origin[mut=mut]](
ImplicitlyCopyable, Sized,
):
...
# @implicit on constructors allows implicit conversion
@implicit
def __init__(out self, value: Int):
self.data = value
The compiler synthesizes copy/move constructors when a struct conforms to Copyable/Movable and all fields support it.
Inside a struct body, always use Self.ParamName — bare parameter names are errors:
# WRONG — bare parameter access
struct Container[T: Writable]:
var data: T # ERROR: use Self.T
def size(self) -> T: # ERROR: use Self.T
# CORRECT — Self-qualified
struct Container[T: Writable]:
var data: Self.T
def size(self) -> Self.T:
return self.data
This applies to all struct parameters (T, N, mut, origin, etc.) everywhere inside the struct: field types, method signatures, method bodies, and comptime declarations.
Types not conforming to ImplicitlyCopyable (e.g., Dict, List) require explicit .copy() or ownership transfer ^:
# WRONG — implicit copy of non-ImplicitlyCopyable type
var d = some_dict
var result = MyStruct(headers=d) # ERROR
# CORRECT — explicit copy or transfer
var result = MyStruct(headers=d.copy()) # or: headers=d^
std. prefixfrom std.testing import assert_equal, TestSuite
from std.algorithm import vectorize
from std.python import PythonObject
import std.random
Prelude auto-imports (no import needed): Int, String, Bool, List, Dict, Optional, SIMD, Float32, Float64, UInt8, Pointer, UnsafePointer, , , , , , , , , , , , , , and more.
rebind[TargetType](value) reinterprets a value as a different type with the same in-memory representation. Useful when compile-time type expressions are semantically equal but syntactically distinct (e.g., LayoutTensor element types — see GPU skill).
Writable / Writer (replaces Stringable)struct MyType(Writable):
var x: Int
def write_to(self, mut writer: Some[Writer]): # for print() / String()
writer.write("MyType(", self.x, ")")
def write_repr_to(self, mut writer: Some[Writer]): # for repr()
t"MyType(x={self.x})".write_to(writer) # t-strings for interpolation
Some[Writer] — builtin existential type (not Writer directly)Writable — simple structs need not implement themString with String.write(value), not str(value)Iterators use raises StopIteration (not Optional):
struct MyCollection(Iterable):
comptime IteratorType[
iterable_mut: Bool, //, iterable_origin: Origin[mut=iterable_mut]
]: Iterator = MyIter[origin=iterable_origin]
def __iter__(ref self) -> Self.IteratorType[origin_of(self)]: ...
# Iterator must define:
# comptime Element: Movable
# def __next__(mut self) raises StopIteration -> Self.Element
For-in: for item in col: (immutable) / for ref item in col: (mutable).
| Type | Use |
|---|---|
Pointer[T, mut=M, origin=O] | Safe, non-nullable. Deref with p[]. |
alloc[T](n) / UnsafePointer | Free function alloc[T](count) → UnsafePointer. .free() required. |
Span(list) | Non-owning contiguous view. |
UnsafePointer has an origin parameter that must be specified for struct fields. Use MutExternalOrigin for owned heap data (this is what stdlib ArcPointer uses):
# Struct field — specify origin explicitly
var _ptr: UnsafePointer[Self.T, MutExternalOrigin]
# Allocate with alloc[]
fn __init__(out self, size: Int):
self._ptr = alloc[Self.T](size)
Mojo tracks reference provenance with origins , not "lifetimes":
struct Span[mut: Bool, //, T: AnyType, origin: Origin[mut=mut]]: ...
Key types: Origin, MutOrigin, ImmutOrigin, MutAnyOrigin, ImmutAnyOrigin, MutExternalOrigin, ImmutExternalOrigin, StaticConstantOrigin. Use origin_of(value) to get a value's origin.
from std.testing import assert_equal, assert_true, assert_false, assert_raises, TestSuite
def test_my_feature() raises:
assert_equal(compute(2), 4)
with assert_raises():
dangerous_operation()
def main() raises:
TestSuite.discover_tests[__functions_in_module()]().run()
Dict entries are iterated directly — no [] deref:
for entry in my_dict.items():
print(entry.key, entry.value) # direct field access, NOT entry[].key
for key in my_dict:
print(key, my_dict[key])
List has no variadic positional constructor. Use bracket literal syntax:
# WRONG — no List[T](elem1, elem2, ...) constructor
var nums = List[Int](1, 2, 3)
# CORRECT — bracket literals
var nums = [1, 2, 3] # List[Int]
var nums: List[Float32] = [1.0, 2.0, 3.0] # explicit element type
var scores = {"alice": 95, "bob": 87} # Dict[String, Int]
| Decorator | Purpose |
|---|---|
@fieldwise_init | Generate fieldwise constructor |
@implicit | Allow implicit conversion |
@always_inline / @always_inline("nodebug") | Force inline |
@no_inline | Prevent inline |
@staticmethod | Static method |
@deprecated("msg") |
No implicit conversions between numeric variables. Use explicit constructors:
var x = Float32(my_int) * scale # CORRECT: Int → Float32
var y = Int(my_uint) # CORRECT: UInt → Int
Literals are polymorphic — FloatLiteral and IntLiteral auto-adapt to context:
var a: Float32 = 0.5 # literal becomes Float32
var b = Float32(x) * 0.003921 # literal adapts — no wrapping needed
var v = SIMD[DType.float32, 4](1.0, 2.0, 3.0, 4.0) # literals adapt
# Construction and lane access
var v = SIMD[DType.float32, 4](1.0, 2.0, 3.0, 4.0)
v[0] # read lane → Scalar[DType.float32]
v[0] = 5.0 # write lane
# Type cast
v.cast[DType.uint32]() # element-wise → SIMD[DType.uint32, 4]
# Clamp (method)
v.clamp(0.0, 1.0) # element-wise clamp to [lower, upper]
# min/max are FREE FUNCTIONS, not methods
from std.math import min, max
min(a, b) # element-wise min (same-type SIMD args)
max(a, b) # element-wise max
# Element-wise ternary via bool SIMD
var mask = (v > 0.0) # SIMD[DType.bool, 4]
mask.select(true_case, false_case) # picks per-lane
# Reductions
v.reduce_add() # horizontal sum → Scalar
v.reduce_max() # horizontal max → Scalar
v.reduce_min() # horizontal min → Scalar
len(s) returns byte length , not codepoint count. Mojo strings are UTF-8. Byte indexing requires keyword syntax: s[byte=idx] (not s[idx]).
var s = "Hello"
len(s) # 5 (bytes)
s.byte_length() # 5 (same as len)
s.count_codepoints() # 5 (codepoint count — differs for non-ASCII)
# Iteration — by codepoint slices (not bytes)
for cp_slice in s.codepoint_slices():
print(cp_slice)
# Codepoint values
for cp in s.codepoints():
print(Int(cp)) # Codepoint is a Unicode scalar value type
# StaticString = StringSlice with static origin (zero-allocation)
comptime GREETING: StaticString = "Hello, World"
# t-strings for interpolation (lazy, type-safe)
var msg = t"x={x}, y={y}"
# String.format() for runtime formatting
var s = "Hello, {}!".format("world")
raises can specify a type. try/except works like Python:
def might_fail() raises -> Int: # raises Error (default)
raise Error("something went wrong")
def parse(s: String) raises Int -> Int: # raises specific type
raise 42
try:
var x = parse("bad")
except err: # err is Int
print("error code:", err)
No match statement. No async/await — use Coroutine/Task from std.runtime.
No lambda syntax. Closures use capturing[origins]:
# Function type with capture
comptime MyFunc = fn(Int) capturing[_] -> None
# Parametric function type (for vectorize etc.)
comptime SIMDFunc = fn[width: Int](Int) capturing[_] -> None
# vectorize pattern
from std.algorithm import vectorize
vectorize[simd_width](size, my_closure)
AnyType
ImplicitlyDestructible — auto __del__; most types
Movable — __init__(out self, *, deinit take: Self)
Copyable — __init__(out self, *, copy: Self)
ImplicitlyCopyable(Copyable, ImplicitlyDestructible)
RegisterPassable(Movable)
TrivialRegisterPassable(ImplicitlyCopyable, ImplicitlyDestructible, Movable, RegisterPassable)
Weekly Installs
93
Repository
GitHub Stars
40
First Seen
13 days ago
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex92
opencode91
gemini-cli87
github-copilot87
cursor87
kimi-cli86
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
118,000 周安装
SpanErrorDTypeWritableWriterCopyableMovableEquatableHashablerebindprintrangelenOwnedPointer[T] | Unique ownership (like Rust Box). |
ArcPointer[T] | Reference-counted shared ownership. |
| Deprecation warning |
@doc_hidden | Hide from docs |
@explicit_destroy | Linear type (no implicit destruction) |