CodeSampleX

サンプル

yoke-derive 0.8.2

検証済みサンプル — cargo yoke-derive 0.8.2. rust 1 · linux alpine/x64 · docker で contract を実行し、成功しました: #[derive(Yokeable)] implements yoke::Yokeable<'a> for…

sha256:eaddc2b3b84febdb3bcf7594d119984182f35e0f44dd163920897f4065c37220

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

ケース

HOW
ゴール
verify pkg:cargo/yoke-derive@0.8.2
パッケージ
作成日
2026-11-06T01:14:23Z

コントラクト

  1. #[derive(Yokeable)] implements yoke::Yokeable<'a> for BorrowedRecord<'static> with Output = BorrowedRecord<'a>
  2. BorrowedRecord::make erases lifetime 'a into BorrowedRecord<'static> and transform reborrows it with key == "alpha" and count == 1
  3. transform_mut mutates the yoked BorrowedRecord in-place (count updated from 1 to 5) and transform_owned recovers BorrowedRecord<'a>

ファイル

  • Cargo.lock
  • Cargo.toml
  • PROMPT.md
  • csx.json
  • spec.json
  • src/main.rs

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

ソース

Cargo.lock
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4

[[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-yoke-derive"
version = "0.1.0"
dependencies = [
 "yoke-derive",
]

[[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 = "synstructure"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2"
dependencies = [
 "proc-macro2",
 "quote",
 "syn",
]

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

[[package]]
name = "yoke-derive"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de844c262c8848816172cef550288e7dc6c7b7814b4ee56b3e1553f275f1858e"
dependencies = [
 "proc-macro2",
 "quote",
 "syn",
 "synstructure",
]
Cargo.toml
[package]
name = "sample-yoke-derive"
version = "0.1.0"
edition = "2021"

[dependencies]
yoke-derive = "=0.8.2"
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/yoke-derive@0.8.2
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:cargo/yoke-derive@0.8.2

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:a2131cc0b4e9fb8fdb7a1191a934bcf5776a693cbaf3da35a47c0c1031f53c52","contract":["#[derive(Yokeable)] implements yoke::Yokeable\u003c'a\u003e for BorrowedRecord\u003c'static\u003e with Output = BorrowedRecord\u003c'a\u003e","BorrowedRecord::make erases lifetime 'a into BorrowedRecord\u003c'static\u003e and transform reborrows it with key == \"alpha\" and count == 1","transform_mut mutates the yoked BorrowedRecord in-place (count updated from 1 to 5) and transform_owned recovers BorrowedRecord\u003c'a\u003e"],"goal":"verify pkg:cargo/yoke-derive@0.8.2","kind":"HOW","packages":["pkg:cargo/yoke-derive@0.8.2"],"schemaVersion":1},"contractCommand":["cargo","run","--offline"],"environment":{"arch":"x64","ecosystem":"cargo","os":"linux","packageManager":"cargo","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/yoke-derive@0.8.2"],"schemaVersion":1,"subject":"pkg:cargo/yoke-derive@0.8.2","verifierAdapter":"cargo@1"}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:cargo/yoke-derive@0.8.2",
  "kind": "HOW",
  "packages": [
    "pkg:cargo/yoke-derive@0.8.2"
  ]
}
src/main.rs
use yoke_derive::Yokeable;

pub mod yoke {
    pub unsafe trait Yokeable<'a>: 'static {
        type Output: 'a;
        fn transform(&'a self) -> &'a Self::Output;
        fn transform_owned(self) -> Self::Output;
        unsafe fn make(from: Self::Output) -> Self;
        fn transform_mut<F>(&'a mut self, f: F)
        where
            F: 'static + for<'b> FnOnce(&'b mut Self::Output);
    }
}

use yoke::Yokeable as _;

#[derive(Yokeable, Debug, PartialEq, Eq)]
pub struct BorrowedRecord<'a> {
    pub key: &'a str,
    pub count: u32,
}

fn verify_yokeable<'a>(key: &'a str) {
    let short = BorrowedRecord { key, count: 1 };
    let mut erased: BorrowedRecord<'static> = unsafe { BorrowedRecord::make(short) };

    {
        let reborrowed = erased.transform();
        assert_eq!(reborrowed.key, key);
        assert_eq!(reborrowed.count, 1);
    }

    erased.transform_mut(|rec| {
        rec.count += 4;
    });
    assert_eq!(erased.transform().count, 5);

    let owned: BorrowedRecord<'a> = erased.transform_owned();
    assert_eq!(owned, BorrowedRecord { key, count: 5 });
}

fn main() {
    let dynamic_key = String::from("alpha");
    verify_yokeable(dynamic_key.as_str());
}

オリジンシーダー

匿名