CodeSampleX

Exemple

ryu 1.0.23

Échantillon vérifié pour cargo ryu 1.0.23. Le contrat s'est exécuté sur rust 1 · linux alpine/x64 · docker et a réussi : Buffer::new and format convert f64…

sha256:7d84891307add5fc73e60f6e3ac3a493a6f862a0f4142fec0134056d18c8e5b3

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 · alpine · musl 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-09-19

Cas

HOW
Objectif
verify pkg:cargo/ryu@1.0.23
Paquets
Créé
2026-09-18T13:23:06Z

Contrat

  1. Buffer::new and format convert f64 floating point values to decimal strings
  2. Buffer::format converts f32 floating point values to decimal strings
  3. Buffer::format converts special non-finite floats to NaN, inf, and -inf strings
  4. Buffer::format_finite formats finite f64 and f32 floating point values
  5. Buffer implements Default and Copy traits for reusable formatting buffers
  6. raw format64 and format32 write decimal bytes directly into raw buffers

Fichiers

  • Cargo.lock
  • Cargo.toml
  • PROMPT.md
  • csx.json
  • spec.json
  • src/lib.rs
  • test/contract.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 = "ryu"
version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"

[[package]]
name = "sample-ryu"
version = "1.0.0"
dependencies = [
 "ryu",
]
Cargo.toml
[package]
name = "sample-ryu"
version = "1.0.0"
edition = "2021"
publish = false

[dependencies]
ryu = "=1.0.23"

[[bin]]
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 pkg:cargo/ryu@1.0.23
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:cargo/ryu@1.0.23

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:7c4dd000bba901d0005ba37c3442744c0938642716b256df0735c761e0bad12e","contract":["Buffer::new and format convert f64 floating point values to decimal strings","Buffer::format converts f32 floating point values to decimal strings","Buffer::format converts special non-finite floats to NaN, inf, and -inf strings","Buffer::format_finite formats finite f64 and f32 floating point values","Buffer implements Default and Copy traits for reusable formatting buffers","raw format64 and format32 write decimal bytes directly into raw buffers"],"goal":"verify pkg:cargo/ryu@1.0.23","kind":"HOW","packages":["pkg:cargo/ryu@1.0.23"],"schemaVersion":1},"contractCommand":["cargo","run","--offline"],"environment":{"arch":"x64","distro":"alpine","ecosystem":"cargo","libc":"musl","os":"linux","packageManager":"cargo","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/ryu@1.0.23"],"schemaVersion":1,"subject":"pkg:cargo/ryu@1.0.23","verifierAdapter":"cargo@1"}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:cargo/ryu@1.0.23",
  "kind": "HOW",
  "packages": [
    "pkg:cargo/ryu@1.0.23"
  ]
}
src/lib.rs
//! Clean-room verification sample for ryu.

pub use ryu::*;
test/contract.rs
use ryu::raw;
use ryu::Buffer;

fn main() {
    // 1. Buffer::new and format convert f64 floating point values to decimal strings
    let mut buffer = Buffer::new();
    let s1 = buffer.format(1.2345f64);
    assert_eq!(s1, "1.2345");
    let s2 = buffer.format(0.0f64);
    assert_eq!(s2, "0.0");
    let s3 = buffer.format(-0.0f64);
    assert_eq!(s3, "-0.0");
    let s4 = buffer.format(1e40f64);
    assert_eq!(s4, "1e40");
    let s5 = buffer.format(1.23e-40f64);
    assert_eq!(s5, "1.23e-40");

    // 2. Buffer::format converts f32 floating point values to decimal strings
    let mut buffer32 = Buffer::new();
    let s32_1 = buffer32.format(1.2345f32);
    assert_eq!(s32_1, "1.2345");
    let s32_2 = buffer32.format(0.0f32);
    assert_eq!(s32_2, "0.0");
    let s32_3 = buffer32.format(-123.456f32);
    assert_eq!(s32_3, "-123.456");

    // 3. Buffer::format converts special non-finite floats to NaN, inf, and -inf strings
    let mut special_buf = Buffer::new();
    assert_eq!(special_buf.format(f64::NAN), "NaN");
    assert_eq!(special_buf.format(f64::INFINITY), "inf");
    assert_eq!(special_buf.format(f64::NEG_INFINITY), "-inf");
    assert_eq!(special_buf.format(f32::NAN), "NaN");
    assert_eq!(special_buf.format(f32::INFINITY), "inf");
    assert_eq!(special_buf.format(f32::NEG_INFINITY), "-inf");

    // 4. Buffer::format_finite formats finite f64 and f32 floating point values
    let mut finite_buf = Buffer::new();
    let f64_str = finite_buf.format_finite(2.718281828459045f64);
    assert_eq!(f64_str, "2.718281828459045");
    let f32_str = finite_buf.format_finite(3.1415927f32);
    assert_eq!(f32_str, "3.1415927");

    // 5. Buffer implements Default and Copy traits for reusable formatting buffers
    let mut def_buf = Buffer::default();
    assert_eq!(def_buf.format(42.0f64), "42.0");
    let mut copy_buf = def_buf;
    assert_eq!(copy_buf.format(100.5f64), "100.5");
    assert_eq!(def_buf.format(200.5f64), "200.5");

    // 6. raw format64 and format32 write decimal bytes directly into raw buffers
    unsafe {
        let mut raw_bytes = [0u8; 32];
        let len64 = raw::format64(12345.6789f64, raw_bytes.as_mut_ptr());
        let str64 = std::str::from_utf8(&raw_bytes[..len64]).unwrap();
        assert_eq!(str64, "12345.6789");

        let len32 = raw::format32(9876.543f32, raw_bytes.as_mut_ptr());
        let str32 = std::str::from_utf8(&raw_bytes[..len32]).unwrap();
        assert_eq!(str32, "9876.543");
    }

    println!("All ryu contract assertions passed successfully.");
}

Seeder d'origine

anonyme