CodeSampleX

Sample

typenum 1.20.1: typenum::Unsigned

Verified sample for cargo typenum 1.20.1: typenum::Unsigned. The contract ran on rust 1 · linux alpine/x64 · docker and passed.

sha256:15e41313e8e28222d6e9e2d28c1b11ab41094e6ca699f646434342da7f2c4976

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-22

Case

HOW
Goal
verify typenum::Unsigned in pkg:cargo/typenum@1.20.1
Packages
Symbols
  • typenum::Unsigned
Created
2026-10-22T17:17:17Z

Contract

  1. typenum::Unsigned associated constants (U8, U16, U32, U64, USIZE) and methods (to_u8, to_u16, to_u32, to_u64, to_usize) evaluate type-level unsigned integers (U0, U42, U1024) to their exact primitive integer values
  2. typenum::Unsigned bounds allow generic functions to extract runtime integer values from type-level unsigned integers
  3. Type-level arithmetic outputs such as Sum<U6, U7> and Prod<U6, U7> implement typenum::Unsigned and evaluate to 13 and 42 respectively

Files

  • Cargo.lock
  • Cargo.toml
  • PROMPT.md
  • csx.json
  • spec.json
  • src/main.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 = "sample-typenum-unsigned"
version = "0.1.0"
dependencies = [
 "typenum",
]

[[package]]
name = "typenum"
version = "1.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
Cargo.toml
[package]
name = "sample-typenum-unsigned"
version = "0.1.0"
edition = "2021"

[dependencies]
typenum = "=1.20.1"
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 typenum::Unsigned in pkg:cargo/typenum@1.20.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:cargo/typenum@1.20.1
Demonstrate these symbols/APIs:
  - typenum::Unsigned

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:00efa40a5c92d6adf2ecf9eeb877c525e7a58278e7cfebc3b9b59c2a2a91ea27","contract":["typenum::Unsigned associated constants (U8, U16, U32, U64, USIZE) and methods (to_u8, to_u16, to_u32, to_u64, to_usize) evaluate type-level unsigned integers (U0, U42, U1024) to their exact primitive integer values","typenum::Unsigned bounds allow generic functions to extract runtime integer values from type-level unsigned integers","Type-level arithmetic outputs such as Sum\u003cU6, U7\u003e and Prod\u003cU6, U7\u003e implement typenum::Unsigned and evaluate to 13 and 42 respectively"],"goal":"verify typenum::Unsigned in pkg:cargo/typenum@1.20.1","kind":"HOW","packages":["pkg:cargo/typenum@1.20.1"],"schemaVersion":1,"symbols":["typenum::Unsigned"]},"contractCommand":["cargo","run","--offline"],"environment":{"arch":"x64","ecosystem":"cargo","os":"linux","packageManager":"cargo","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/typenum@1.20.1"],"schemaVersion":1,"subject":"pkg:cargo/typenum@1.20.1","symbols":["typenum::Unsigned"],"verifierAdapter":"cargo@1"}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify typenum::Unsigned in pkg:cargo/typenum@1.20.1",
  "kind": "HOW",
  "packages": [
    "pkg:cargo/typenum@1.20.1"
  ],
  "symbols": [
    "typenum::Unsigned"
  ]
}
src/main.rs
use std::ops::{Add, Mul};
use typenum::{Sum, Prod, Unsigned, U0, U7, U6, U42, U1024};

fn eval_unsigned<N: Unsigned>() -> (usize, u64, u32, u16, u8) {
    (N::USIZE, N::U64, N::to_u32(), N::to_u16(), N::to_u8())
}

fn main() {
    // 1. Direct evaluation of type-level unsigned integers via Unsigned trait constants and methods
    assert_eq!(U0::USIZE, 0);
    assert_eq!(U0::to_u64(), 0);

    assert_eq!(U42::U8, 42);
    assert_eq!(U42::U16, 42);
    assert_eq!(U42::U32, 42);
    assert_eq!(U42::U64, 42);
    assert_eq!(U42::USIZE, 42);
    assert_eq!(U42::to_u8(), 42);
    assert_eq!(U42::to_u16(), 42);
    assert_eq!(U42::to_u32(), 42);
    assert_eq!(U42::to_u64(), 42);
    assert_eq!(U42::to_usize(), 42);

    // 2. Generic bound usage with Unsigned
    assert_eq!(eval_unsigned::<U42>(), (42, 42, 42, 42, 42));
    assert_eq!(U1024::to_u16(), 1024);
    assert_eq!(U1024::USIZE, 1024);

    // 3. Type-level arithmetic results implementing Unsigned
    type SixPlusSeven = Sum<U6, U7>;
    type SixTimesSeven = Prod<U6, U7>;
    assert_eq!(<SixPlusSeven as Unsigned>::to_usize(), 13);
    assert_eq!(<SixTimesSeven as Unsigned>::to_u64(), 42);
    assert_eq!(<<U6 as Add<U7>>::Output as Unsigned>::USIZE, 13);
    assert_eq!(<<U6 as Mul<U7>>::Output as Unsigned>::U32, 42);
}

Origin Seeder

anonymous