示例
wasm-bindgen-macro-support 0.2.128: expand_struct_marker
已验证示例 — cargo wasm-bindgen-macro-support 0.2.128: expand_struct_marker. contract 在 rust 1 · linux alpine/x64 · docker 上运行并通过:…
sha256:ee4abbb28b20d4c0ebdb1859a8ca182cb2e5258beccad04ebbb0167660c1f1ba
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 1
- 构建过它的签名密钥
- 1
声明的环境
linux x64 cargo
验证运行环境
| 环境 | 契约 | 阶段 | 运行日期 |
|---|---|---|---|
| rust 1 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · cargo@1rust:1-alpine@sha256:a10e64dd139b… |
2026-10-17 |
案例
HOW- 目标
- verify expand_struct_marker in pkg:cargo/wasm-bindgen-macro-support@0.2.128
- 符号
-
- expand_struct_marker
- 创建时间
- 2026-10-17T11:54:37Z
契约
- expand_struct_marker("#[wasm_bindgen(inspectable)] pub struct Point { pub x: i32, #[wasm_bindgen(readonly)] pub id: u32 }") generates WasmDescribe, IntoWasmAbi, FromWasmAbi, __wbg_get_point_x, __wbg_set_point_x, and __wbg_get_point_id without __wbg_set_point_id
- expand_struct_marker("pub fn not_a_struct() {}") returns Err(Diagnostic)
文件
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- src/main.rs
- test/contract.rs
源代码
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "bumpalo"
version = "3.20.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"
[[package]]
name = "proc-macro2"
version = "1.0.107"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
dependencies = [
"proc-macro2",
]
[[package]]
name = "sample-expand-struct-marker"
version = "0.1.0"
dependencies = [
"wasm-bindgen-macro-support",
]
[[package]]
name = "syn"
version = "3.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "unicode-ident"
version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.128"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "411e4887f0071ef2d2164a9d5fdf2d20efbef78fccd3a78b0c10a1dc5295e48a"
dependencies = [
"bumpalo",
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.128"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81941cd78d0c92026c33e5e01312845a4cb1e9af3407f9134b100dd03144103e"
dependencies = [
"unicode-ident",
]
[package]
name = "sample-expand-struct-marker"
version = "0.1.0"
edition = "2021"
[dependencies]
wasm-bindgen-macro-support = "=0.2.128"
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify expand_struct_marker in pkg:cargo/wasm-bindgen-macro-support@0.2.128
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/wasm-bindgen-macro-support@0.2.128
Demonstrate these symbols/APIs:
- expand_struct_marker
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:4c0328e1622384a276971a6c35e4d30d006ba91f9e69f8ddc6e012fa61dffa4c","contract":["expand_struct_marker(\"#[wasm_bindgen(inspectable)] pub struct Point { pub x: i32, #[wasm_bindgen(readonly)] pub id: u32 }\") generates WasmDescribe, IntoWasmAbi, FromWasmAbi, __wbg_get_point_x, __wbg_set_point_x, and __wbg_get_point_id without __wbg_set_point_id","expand_struct_marker(\"pub fn not_a_struct() {}\") returns Err(Diagnostic)"],"goal":"verify expand_struct_marker in pkg:cargo/wasm-bindgen-macro-support@0.2.128","kind":"HOW","packages":["pkg:cargo/wasm-bindgen-macro-support@0.2.128"],"schemaVersion":1,"symbols":["expand_struct_marker"]},"contractCommand":["cargo","run","--offline"],"environment":{"arch":"x64","ecosystem":"cargo","os":"linux","packageManager":"cargo","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/wasm-bindgen-macro-support@0.2.128"],"schemaVersion":1,"subject":"pkg:cargo/wasm-bindgen-macro-support@0.2.128","symbols":["expand_struct_marker"],"verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify expand_struct_marker in pkg:cargo/wasm-bindgen-macro-support@0.2.128",
"kind": "HOW",
"packages": [
"pkg:cargo/wasm-bindgen-macro-support@0.2.128"
],
"symbols": [
"expand_struct_marker"
]
}
#[path = "../test/contract.rs"]
mod contract;
fn main() {
contract::verify();
}
use wasm_bindgen_macro_support::expand_struct_marker;
pub fn verify() {
// 1. Public fields generate WasmDescribe, IntoWasmAbi, FromWasmAbi, and both getter and setter glue.
let inspectable_out = expand_struct_marker(
"#[wasm_bindgen(inspectable)] pub struct Point { pub x: i32, #[wasm_bindgen(readonly)] pub id: u32 }"
.parse()
.unwrap(),
)
.expect("expand_struct_marker on valid struct should return Ok")
.to_string();
assert!(
inspectable_out.contains("WasmDescribe")
&& inspectable_out.contains("IntoWasmAbi")
&& inspectable_out.contains("FromWasmAbi"),
"expected ABI trait implementations in expansion: {inspectable_out}"
);
assert!(
inspectable_out.contains("__wbg_get_point_x")
&& inspectable_out.contains("__wbg_set_point_x"),
"expected both getter and setter for mutable public field x: {inspectable_out}"
);
assert!(
inspectable_out.contains("__wbg_get_point_id")
&& !inspectable_out.contains("__wbg_set_point_id"),
"expected getter only (no setter) for readonly public field id: {inspectable_out}"
);
// 2. Non-struct items passed to expand_struct_marker return Err(Diagnostic).
let err = expand_struct_marker("pub fn not_a_struct() {}".parse().unwrap())
.expect_err("expand_struct_marker on a function item must return Err");
let err_dbg = format!("{err:?}");
assert!(
!err_dbg.is_empty(),
"expected non-empty Diagnostic debug output on invalid item"
);
}
原始种子者
匿名