CodeSampleX

Sample

zerofrom-derive 0.1.7: zerofrom_derive::ZeroFrom

Verified sample for cargo zerofrom-derive 0.1.7: zerofrom_derive::ZeroFrom. The contract ran on rust 1 · linux alpine/x64 · docker and passed.

sha256:1a19921312c1c91b3b60e7c2fcfa9837c9d1ea2627c5e2ae53cb911db1ba5e65

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment linux x64 cargo

Verification-run environments

Environment Contract Stages Run
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

Case

HOW
Goal
verify zerofrom_derive::ZeroFrom in pkg:cargo/zerofrom-derive@0.1.7
Packages
Symbols
  • zerofrom_derive::ZeroFrom
Created
2026-11-06T02:21:40Z

Contract

  1. #[derive(ZeroFrom)] on a struct with lifetime-borrowed fields projects &'a str and &'a [u8] fields via zerofrom::ZeroFrom::zero_from
  2. #[zerofrom(copy)] copies Copy fields such as u32 directly during ZeroFrom::zero_from projection
  3. #[zerofrom(clone)] clones Clone fields such as String during ZeroFrom::zero_from projection
  4. #[derive(ZeroFrom)] on a lifetime-parameterized enum projects both borrowed and #[zerofrom(copy)] variants

Files

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

Download the source artifact (tar.gz)

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

[[package]]
name = "zerofrom-derive-sample"
version = "0.1.0"
dependencies = [
 "zerofrom-derive",
]
Cargo.toml
[package]
name = "zerofrom-derive-sample"
version = "0.1.0"
edition = "2021"
publish = false

[[test]]
name = "contract"
path = "test/contract.rs"

[dependencies]
zerofrom-derive = "=0.1.7"
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 zerofrom_derive::ZeroFrom in pkg:cargo/zerofrom-derive@0.1.7
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:cargo/zerofrom-derive@0.1.7
Demonstrate these symbols/APIs:
  - zerofrom_derive::ZeroFrom

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:8b7849b0908971e742404f1c103a0a7edec77111c97512bbf0bf05b14c6ab1f4","contract":["#[derive(ZeroFrom)] on a struct with lifetime-borrowed fields projects \u0026'a str and \u0026'a [u8] fields via zerofrom::ZeroFrom::zero_from","#[zerofrom(copy)] copies Copy fields such as u32 directly during ZeroFrom::zero_from projection","#[zerofrom(clone)] clones Clone fields such as String during ZeroFrom::zero_from projection","#[derive(ZeroFrom)] on a lifetime-parameterized enum projects both borrowed and #[zerofrom(copy)] variants"],"goal":"verify zerofrom_derive::ZeroFrom in pkg:cargo/zerofrom-derive@0.1.7","kind":"HOW","packages":["pkg:cargo/zerofrom-derive@0.1.7"],"schemaVersion":1,"symbols":["zerofrom_derive::ZeroFrom"]},"contractCommand":["cargo","run","--offline"],"environment":{"arch":"x64","ecosystem":"cargo","os":"linux","packageManager":"cargo","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/zerofrom-derive@0.1.7"],"schemaVersion":1,"subject":"pkg:cargo/zerofrom-derive@0.1.7","symbols":["zerofrom_derive::ZeroFrom"],"verifierAdapter":"cargo@1"}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify zerofrom_derive::ZeroFrom in pkg:cargo/zerofrom-derive@0.1.7",
  "kind": "HOW",
  "packages": [
    "pkg:cargo/zerofrom-derive@0.1.7"
  ],
  "symbols": [
    "zerofrom_derive::ZeroFrom"
  ]
}
src/main.rs
use zerofrom_derive::ZeroFrom;

pub mod zerofrom {
    pub trait ZeroFrom<'zf, C: ?Sized> {
        fn zero_from(other: &'zf C) -> Self;
    }

    impl<'zf, 'a> ZeroFrom<'zf, &'a str> for &'zf str {
        fn zero_from(other: &'zf &'a str) -> Self {
            *other
        }
    }

    impl<'zf, 'a, T> ZeroFrom<'zf, &'a [T]> for &'zf [T] {
        fn zero_from(other: &'zf &'a [T]) -> Self {
            *other
        }
    }
}

#[derive(ZeroFrom, Debug, PartialEq)]
pub struct Record<'a> {
    pub label: &'a str,
    pub bytes: &'a [u8],
    #[zerofrom(copy)]
    pub code: u32,
    #[zerofrom(clone)]
    pub tag: String,
}

#[derive(ZeroFrom, Debug, PartialEq)]
pub enum Item<'a> {
    Text(&'a str),
    Code(#[zerofrom(copy)] u16),
}

fn verify_zerofrom_derive() {
    let source_label = String::from("alpha");
    let source_bytes = vec![1_u8, 2, 3];
    let original = Record {
        label: source_label.as_str(),
        bytes: source_bytes.as_slice(),
        code: 42,
        tag: String::from("owned-tag"),
    };

    let projected: Record<'_> = zerofrom::ZeroFrom::zero_from(&original);
    assert_eq!(projected.label, "alpha");
    assert_eq!(projected.bytes, &[1, 2, 3]);
    assert_eq!(projected.code, 42);
    assert_eq!(projected.tag, "owned-tag");

    let item_text = Item::Text(source_label.as_str());
    let projected_text: Item<'_> = zerofrom::ZeroFrom::zero_from(&item_text);
    assert_eq!(projected_text, Item::Text("alpha"));

    let item_code = Item::Code(7);
    let projected_code: Item<'_> = zerofrom::ZeroFrom::zero_from(&item_code);
    assert_eq!(projected_code, Item::Code(7));
}

fn main() {
    verify_zerofrom_derive();
}
test/contract.rs
use zerofrom_derive::ZeroFrom;

pub mod zerofrom {
    pub trait ZeroFrom<'zf, C: ?Sized> {
        fn zero_from(other: &'zf C) -> Self;
    }

    impl<'zf, 'a> ZeroFrom<'zf, &'a str> for &'zf str {
        fn zero_from(other: &'zf &'a str) -> Self {
            *other
        }
    }

    impl<'zf, 'a, T> ZeroFrom<'zf, &'a [T]> for &'zf [T] {
        fn zero_from(other: &'zf &'a [T]) -> Self {
            *other
        }
    }
}

#[derive(ZeroFrom, Debug, PartialEq)]
pub struct Record<'a> {
    pub label: &'a str,
    pub bytes: &'a [u8],
    #[zerofrom(copy)]
    pub code: u32,
    #[zerofrom(clone)]
    pub tag: String,
}

#[derive(ZeroFrom, Debug, PartialEq)]
pub enum Item<'a> {
    Text(&'a str),
    Code(#[zerofrom(copy)] u16),
}

#[test]
fn contract_zerofrom_derive() {
    let source_label = String::from("alpha");
    let source_bytes = vec![1_u8, 2, 3];
    let original = Record {
        label: source_label.as_str(),
        bytes: source_bytes.as_slice(),
        code: 42,
        tag: String::from("owned-tag"),
    };

    let projected: Record<'_> = zerofrom::ZeroFrom::zero_from(&original);
    assert_eq!(projected.label, "alpha");
    assert_eq!(projected.bytes, &[1, 2, 3]);
    assert_eq!(projected.code, 42);
    assert_eq!(projected.tag, "owned-tag");

    let item_text = Item::Text(source_label.as_str());
    let projected_text: Item<'_> = zerofrom::ZeroFrom::zero_from(&item_text);
    assert_eq!(projected_text, Item::Text("alpha"));

    let item_code = Item::Code(7);
    let projected_code: Item<'_> = zerofrom::ZeroFrom::zero_from(&item_code);
    assert_eq!(projected_code, Item::Code(7));
}

Origin Seeder

anonymous