CodeSampleX

Sample

num-conv 0.2.2: num_conv::Widen

Verified sample for cargo num-conv 0.2.2: num_conv::Widen. The contract ran on rust 1 · linux alpine/x64 · docker and passed: Widen::widen widens unsigned…

sha256:d2bdec0486f68407156d8e2844e0ec7bf835fe8f824cef80584e34a329d4b95e

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-10-31

Case

HOW
Goal
verify num_conv::Widen in pkg:cargo/num-conv@0.2.2
Packages
Symbols
  • num_conv::Widen
Created
2026-10-31T01:57:04Z

Contract

  1. Widen::widen widens unsigned integers (u8 to u16/u32/u64/u128/usize, u16 to u32/u64/u128/usize, u32 to u64/u128, u64 to u128) preserving numeric value without unstable method name collision warnings
  2. Widen::widen sign-extends signed integers (i8 to i16/i32/i64/i128/isize, i16 to i32/i64/i128/isize) preserving negative values

Files

  • Cargo.lock
  • Cargo.toml
  • PROMPT.md
  • csx.json
  • spec.json
  • src/lib.rs
  • 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 = "num-conv"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441"

[[package]]
name = "sample-num-conv-widen"
version = "0.1.0"
dependencies = [
 "num-conv",
]
Cargo.toml
[package]
name = "sample-num-conv-widen"
version = "0.1.0"
edition = "2021"

[dependencies]
num-conv = "=0.2.2"

[[test]]
name = "contract"
path = "test/contract.rs"
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 num_conv::Widen in pkg:cargo/num-conv@0.2.2
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:cargo/num-conv@0.2.2
Demonstrate these symbols/APIs:
  - num_conv::Widen

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:e6d9d93d5867ec5abb052e54be658487bf35f4e7678e2e95190ae0e198a1506f","contract":["Widen::widen widens unsigned integers (u8 to u16/u32/u64/u128/usize, u16 to u32/u64/u128/usize, u32 to u64/u128, u64 to u128) preserving numeric value without unstable method name collision warnings","Widen::widen sign-extends signed integers (i8 to i16/i32/i64/i128/isize, i16 to i32/i64/i128/isize) preserving negative values"],"goal":"verify num_conv::Widen in pkg:cargo/num-conv@0.2.2","kind":"HOW","packages":["pkg:cargo/num-conv@0.2.2"],"schemaVersion":1,"symbols":["num_conv::Widen"]},"contractCommand":["cargo","run","--offline"],"environment":{"arch":"x64","ecosystem":"cargo","os":"linux","packageManager":"cargo","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/num-conv@0.2.2"],"schemaVersion":1,"subject":"pkg:cargo/num-conv@0.2.2","symbols":["num_conv::Widen"],"verifierAdapter":"cargo@1"}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify num_conv::Widen in pkg:cargo/num-conv@0.2.2",
  "kind": "HOW",
  "packages": [
    "pkg:cargo/num-conv@0.2.2"
  ],
  "symbols": [
    "num_conv::Widen"
  ]
}
src/lib.rs
use num_conv::Widen;

pub fn run_contract() {
    // Unsigned integer widening via Widen::widen without unstable method name collision warnings
    let u8_val: u8 = 250;
    let widened_u16: u16 = Widen::widen(u8_val);
    let widened_u32: u32 = Widen::widen(u8_val);
    let widened_u64: u64 = Widen::widen(u8_val);
    let widened_u128: u128 = Widen::widen(u8_val);
    let widened_usize: usize = Widen::widen(u8_val);
    assert_eq!(widened_u16, 250);
    assert_eq!(widened_u32, 250);
    assert_eq!(widened_u64, 250);
    assert_eq!(widened_u128, 250);
    assert_eq!(widened_usize, 250);

    // Widening from wider unsigned types (u16 -> u32, u64, u128, usize; u32 -> u64, u128; u64 -> u128)
    let u16_val: u16 = 60_000;
    let u16_to_u32: u32 = Widen::widen(u16_val);
    let u16_to_u64: u64 = Widen::widen(u16_val);
    let u16_to_u128: u128 = Widen::widen(u16_val);
    let u16_to_usize: usize = Widen::widen(u16_val);
    assert_eq!(u16_to_u32, 60_000);
    assert_eq!(u16_to_u64, 60_000);
    assert_eq!(u16_to_u128, 60_000);
    assert_eq!(u16_to_usize, 60_000);

    let u32_val: u32 = 4_000_000_000;
    let u32_to_u64: u64 = Widen::widen(u32_val);
    let u32_to_u128: u128 = Widen::widen(u32_val);
    assert_eq!(u32_to_u64, 4_000_000_000);
    assert_eq!(u32_to_u128, 4_000_000_000);

    let u64_val: u64 = 10_000_000_000_000;
    let u64_to_u128: u128 = Widen::widen(u64_val);
    assert_eq!(u64_to_u128, 10_000_000_000_000);

    // Signed integer sign-extending widening via Widen::widen
    let i8_val: i8 = -42;
    let widened_i16: i16 = Widen::widen(i8_val);
    let widened_i32: i32 = Widen::widen(i8_val);
    let widened_i64: i64 = Widen::widen(i8_val);
    let widened_i128: i128 = Widen::widen(i8_val);
    let widened_isize: isize = Widen::widen(i8_val);
    assert_eq!(widened_i16, -42);
    assert_eq!(widened_i32, -42);
    assert_eq!(widened_i64, -42);
    assert_eq!(widened_i128, -42);
    assert_eq!(widened_isize, -42);

    // Widening from wider signed types (i16 -> i32, i64, i128, isize; i32 -> i64, i128; i64 -> i128)
    let i16_val: i16 = -30_000;
    let i16_to_i32: i32 = Widen::widen(i16_val);
    let i16_to_i64: i64 = Widen::widen(i16_val);
    let i16_to_i128: i128 = Widen::widen(i16_val);
    let i16_to_isize: isize = Widen::widen(i16_val);
    assert_eq!(i16_to_i32, -30_000);
    assert_eq!(i16_to_i64, -30_000);
    assert_eq!(i16_to_i128, -30_000);
    assert_eq!(i16_to_isize, -30_000);
}
src/main.rs
fn main() {
    sample_num_conv_widen::run_contract();
}
test/contract.rs
#[test]
fn contract() {
    sample_num_conv_widen::run_contract();
}

Origin Seeder

anonymous