示例
ryu 1.0.23
已验证示例 — cargo ryu 1.0.23. contract 在 rust 1 · linux alpine/x64 · docker 上运行并通过: Buffer::new and format convert f64 floating point values to decimal strings
sha256:7d84891307add5fc73e60f6e3ac3a493a6f862a0f4142fec0134056d18c8e5b3
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 1
- 构建过它的签名密钥
- 1
声明的环境
linux · alpine · musl x64 cargo
验证运行环境
| 环境 | 契约 | 阶段 | 运行日期 |
|---|---|---|---|
| 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 |
案例
HOW- 目标
- verify pkg:cargo/ryu@1.0.23
- 创建时间
- 2026-09-18T13:23:06Z
契约
- 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
文件
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- src/lib.rs
- test/contract.rs
源代码
# 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",
]
[package]
name = "sample-ryu"
version = "1.0.0"
edition = "2021"
publish = false
[dependencies]
ryu = "=1.0.23"
[[bin]]
name = "contract"
path = "test/contract.rs"
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.
{"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"}
{
"schemaVersion": 1,
"goal": "verify pkg:cargo/ryu@1.0.23",
"kind": "HOW",
"packages": [
"pkg:cargo/ryu@1.0.23"
]
}
//! Clean-room verification sample for ryu.
pub use ryu::*;
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.");
}
原始种子者
匿名