CodeSampleX

Exemple

yoke-derive 0.8.2: yoke_derive::Yokeable

Échantillon vérifié pour cargo yoke-derive 0.8.2: yoke_derive::Yokeable. Le contrat s'est exécuté sur rust 1 · linux alpine/x64 · docker et a réussi.

sha256:60e9c292082f7a23b3aa79be779b7db77a2a55a65f811d0184c58bf75b2dc3d1

Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré. Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes. MIT-0

Preuves d'exécution

L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.

Base de preuve
Contrat signé réussi
Reçus de vérification
1
Clés de signature qui l’ont compilé
1
Environnement déclaré linux x64 cargo

Environnements des exécutions de vérification

Environnement Contrat Étapes Exécution
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

Cas

HOW
Objectif
verify yoke_derive::Yokeable in pkg:cargo/yoke-derive@0.8.2
Paquets
Symboles
  • yoke_derive::Yokeable
Créé
2026-11-06T01:41:11Z

Contrat

  1. Derives yoke::Yokeable on a struct with a lifetime parameter using #[derive(yoke_derive::Yokeable)]
  2. Transforms BorrowedData<'static> to &BorrowedData<'a> via Yokeable::transform and verifies field equality
  3. Mutates the yoked struct in place via Yokeable::transform_mut and verifies the updated field value
  4. Converts BorrowedData<'static> to BorrowedData<'a> by value via Yokeable::transform_owned

Fichiers

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

Télécharger l’artefact source (tar.gz)

Code source

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

[[package]]
name = "stable_deref_trait"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596"

[[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"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abe8c5fda708d9ca3df187cae8bfb9ceda00dd96231bed36e445a1a48e66f9ca"
dependencies = [
 "stable_deref_trait",
 "zerofrom",
]

[[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",
]

[[package]]
name = "zerofrom"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272"
Cargo.toml
[package]
name = "sample"
version = "0.1.0"
edition = "2021"

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

Use EXACTLY these public packages and versions:
  - pkg:cargo/yoke-derive@0.8.2
Demonstrate these symbols/APIs:
  - yoke_derive::Yokeable

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:dbfefbc9622a47eeba11c5031ce77210cf2670bacd7e19bb26eedcca8441ea5e","contract":["Derives yoke::Yokeable on a struct with a lifetime parameter using #[derive(yoke_derive::Yokeable)]","Transforms BorrowedData\u003c'static\u003e to \u0026BorrowedData\u003c'a\u003e via Yokeable::transform and verifies field equality","Mutates the yoked struct in place via Yokeable::transform_mut and verifies the updated field value","Converts BorrowedData\u003c'static\u003e to BorrowedData\u003c'a\u003e by value via Yokeable::transform_owned"],"goal":"verify yoke_derive::Yokeable in pkg:cargo/yoke-derive@0.8.2","kind":"HOW","packages":["pkg:cargo/yoke-derive@0.8.2"],"schemaVersion":1,"symbols":["yoke_derive::Yokeable"]},"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","symbols":["yoke_derive::Yokeable"],"verifierAdapter":"cargo@1"}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify yoke_derive::Yokeable in pkg:cargo/yoke-derive@0.8.2",
  "kind": "HOW",
  "packages": [
    "pkg:cargo/yoke-derive@0.8.2"
  ],
  "symbols": [
    "yoke_derive::Yokeable"
  ]
}
src/main.rs
use std::borrow::Cow;
use yoke::Yokeable;

#[derive(yoke_derive::Yokeable, Debug, PartialEq, Clone)]
struct BorrowedData<'a> {
    text: Cow<'a, str>,
}

fn main() {
    let owned: BorrowedData<'static> = BorrowedData {
        text: Cow::Borrowed("hello yoke"),
    };
    let borrowed: &BorrowedData<'_> = owned.transform();
    assert_eq!(borrowed.text, "hello yoke");

    let mut owned_mut = owned.clone();
    owned_mut.transform_mut(|b| {
        b.text = Cow::Owned(format!("{}!", b.text));
    });
    assert_eq!(owned_mut.text, "hello yoke!");

    let transformed_owned: BorrowedData<'_> = owned.transform_owned();
    assert_eq!(transformed_owned.text, "hello yoke");
}

Seeder d'origine

anonyme