CodeSampleX

サンプル

wasm-bindgen-macro-support 0.2.127

検証済みサンプル — cargo wasm-bindgen-macro-support 0.2.127. rust 1 · linux alpine/x64 · docker で contract を実行し、成功しました: expand expands a public function into…

sha256:36ca898190a3f08f13e077e809f5cf5a0dc9618cb87cf89178b8c80f8a2d8535

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 MIT-0

実行証拠

宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。

証拠の基準
署名済みコントラクト合格
検証レシート
1
ビルドした署名鍵
1
宣言された環境 linux · alpine · musl 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-09-19

ケース

HOW
ゴール
verify pkg:cargo/wasm-bindgen-macro-support@0.2.127
パッケージ
作成日
2026-09-19T14:03:24Z

コントラクト

  1. expand expands a public function into bindings tokens
  2. expand expands a struct into BindgenedStruct derive tokens
  3. expand expands an enum and preserves enum variants
  4. expand returns Err(Diagnostic) on invalid input syntax
  5. expand_link_to generates link module bindings tokens for an absolute raw_module path

ファイル

  • Cargo.lock
  • Cargo.toml
  • NOTES.md
  • PROMPT.md
  • csx.json
  • spec.json
  • src/lib.rs
  • test/contract.rs

ソースアーティファクトをダウンロード (tar.gz)

ソース

Cargo.lock
# 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-wasm-bindgen-macro-support"
version = "1.0.0"
dependencies = [
 "proc-macro2",
 "quote",
 "syn",
 "wasm-bindgen-macro-support",
]

[[package]]
name = "syn"
version = "2.0.119"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
dependencies = [
 "proc-macro2",
 "quote",
 "unicode-ident",
]

[[package]]
name = "unicode-ident"
version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954"

[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.127"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e11d33f857dc2fb11b8bc75aee111aa9cbeb12cd9f25efd3d4c2a3dd4e235284"
dependencies = [
 "bumpalo",
 "proc-macro2",
 "quote",
 "syn",
 "wasm-bindgen-shared",
]

[[package]]
name = "wasm-bindgen-shared"
version = "0.2.127"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ef64dbcc55df09c7e5a46182d181c2cfa3e925f3da937ea764728b4bbb9dcbf"
dependencies = [
 "unicode-ident",
]
Cargo.toml
[package]
name = "sample-wasm-bindgen-macro-support"
version = "1.0.0"
edition = "2021"
publish = false

[dependencies]
wasm-bindgen-macro-support = "=0.2.127"
proc-macro2 = "1.0"
quote = "1.0"
syn = { version = "2.0", features = ["full"] }

[[bin]]
name = "contract"
path = "test/contract.rs"
NOTES.md
# wasm-bindgen-macro-support 0.2.127 API Contracts

## What `search_known_solution` answered
`search_known_solution` returned an empty scaffold with unverified contract. This sample verifies the actual 0.2.127 expansion contracts.

## What a model would have written instead
A model may confuse `wasm-bindgen-macro-support` (the library crate) with `wasm-bindgen-macro` (the procedural macro attribute crate) or pass relative module paths to `expand_link_to` which fails with "relative module paths aren't supported yet".

## How the wrong version fails
Calling `expand_link_to` with relative paths results in a Diagnostic error. In addition, macro expansion requires syn 2.0 and proc-macro2 token streams rather than standard strings.
PROMPT.md
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 pkg:cargo/wasm-bindgen-macro-support@0.2.127
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:cargo/wasm-bindgen-macro-support@0.2.127

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.
csx.json
{"case":{"caseId":"case:sha256:b272625be5189504af52b2172e0908f097cbc7d22e41ea99ed4751820d6b5bf5","contract":["expand expands a public function into bindings tokens","expand expands a struct into BindgenedStruct derive tokens","expand expands an enum and preserves enum variants","expand returns Err(Diagnostic) on invalid input syntax","expand_link_to generates link module bindings tokens for an absolute raw_module path"],"goal":"verify pkg:cargo/wasm-bindgen-macro-support@0.2.127","kind":"HOW","packages":["pkg:cargo/wasm-bindgen-macro-support@0.2.127"],"schemaVersion":1},"contractCommand":["cargo","run","--offline"],"environment":{"arch":"x64","distro":"alpine","ecosystem":"cargo","libc":"musl","os":"linux","packageManager":"cargo","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/wasm-bindgen-macro-support@0.2.127"],"schemaVersion":1,"subject":"pkg:cargo/wasm-bindgen-macro-support@0.2.127","verifierAdapter":"cargo@1"}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:cargo/wasm-bindgen-macro-support@0.2.127",
  "kind": "HOW",
  "packages": [
    "pkg:cargo/wasm-bindgen-macro-support@0.2.127"
  ]
}
src/lib.rs
//! Clean-room verification sample for wasm-bindgen-macro-support.

pub use wasm_bindgen_macro_support::*;
test/contract.rs
use quote::quote;
use wasm_bindgen_macro_support::{expand, expand_link_to};

fn main() {
    // 1. expand expands a public function into bindings tokens
    let fn_attr = quote!();
    let fn_item = quote!(
        pub fn add(a: u32, b: u32) -> u32 {
            a + b
        }
    );
    let fn_tokens = expand(fn_attr, fn_item).expect("expand function should succeed");
    let fn_str = fn_tokens.to_string();
    assert!(fn_str.contains("add"), "generated tokens should contain function name");

    // 2. expand expands a struct into BindgenedStruct derive tokens
    let struct_attr = quote!();
    let struct_item = quote!(
        pub struct User {
            pub id: u32,
        }
    );
    let struct_tokens = expand(struct_attr, struct_item).expect("expand struct should succeed");
    let struct_str = struct_tokens.to_string();
    assert!(struct_str.contains("BindgenedStruct"), "struct output should contain BindgenedStruct");

    // 3. expand expands an enum and preserves enum variants
    let enum_attr = quote!();
    let enum_item = quote!(
        pub enum Status {
            Active,
            Inactive,
        }
    );
    let enum_tokens = expand(enum_attr, enum_item).expect("expand enum should succeed");
    let enum_str = enum_tokens.to_string();
    assert!(enum_str.contains("Status"), "enum output should contain enum identifier");

    // 4. expand returns Err(Diagnostic) on invalid input syntax
    let invalid_attr = quote!();
    let invalid_item = quote!(
        not a valid rust item syntax !!!
    );
    let err_res = expand(invalid_attr, invalid_item);
    assert!(err_res.is_err(), "expand should fail on invalid syntax");

    // 5. expand_link_to generates link module bindings tokens for an absolute raw_module path
    let link_input = quote!(raw_module = "/bundle.js");
    let link_tokens = expand_link_to(link_input).expect("expand_link_to should succeed");
    let link_str = link_tokens.to_string();
    assert!(!link_str.is_empty(), "link_to tokens should not be empty");

    println!("All wasm-bindgen-macro-support contract assertions passed successfully.");
}

オリジンシーダー

匿名