CodeSampleX

示例

js-sys 0.3.104

已验证示例 — cargo js-sys 0.3.104. contract 在 rust 1 · linux alpine/x64 · docker 上运行并通过: Number constants MAX_SAFE_INTEGER and MIN_SAFE_INTEGER define 53-bit…

sha256:cc4f8d2351c27f635ef3f8cb983f1dad144e2abc5c6355a1e0d64dd04832c6f6

本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。 提交了通过的契约回执的不同签名密钥数量。为 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/js-sys@0.3.104
包
创建时间
2026-09-19T03:26:07Z

契约

  1. Number constants MAX_SAFE_INTEGER and MIN_SAFE_INTEGER define 53-bit integer boundaries
  2. Number constants EPSILON, MAX_VALUE, and MIN_VALUE define float precision limits
  3. Number constants NAN, POSITIVE_INFINITY, and NEGATIVE_INFINITY represent special float values
  4. Number::try_from rejects integers exceeding safe bounds with TryFromIntError
  5. TryFromIntError implements Display formatting and std::error::Error

文件

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

下载源代码构件 (tar.gz)

源代码

Cargo.lock
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4

[[package]]
name = "bumpalo"
version = "3.20.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"

[[package]]
name = "cfg-if"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"

[[package]]
name = "futures-core"
version = "0.3.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e"

[[package]]
name = "futures-task"
version = "0.3.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd"

[[package]]
name = "futures-util"
version = "0.3.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc"
dependencies = [
 "futures-core",
 "futures-task",
 "pin-project-lite",
 "slab",
]

[[package]]
name = "js-sys"
version = "0.3.104"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e0c1080212aad755ea003d18543e8768dd432c48819efd73a7bf1e39b7a5a3a"
dependencies = [
 "cfg-if",
 "futures-util",
 "wasm-bindgen",
]

[[package]]
name = "once_cell"
version = "1.21.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"

[[package]]
name = "pin-project-lite"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"

[[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 = "rustversion"
version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"

[[package]]
name = "sample-js-sys"
version = "1.0.0"
dependencies = [
 "js-sys",
]

[[package]]
name = "slab"
version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"

[[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 = "unicode-ident"
version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954"

[[package]]
name = "wasm-bindgen"
version = "0.2.127"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b70935747edd64d89de3efa29d73789b806c15798f8e7dca4d8ac356b50ce70"
dependencies = [
 "cfg-if",
 "once_cell",
 "rustversion",
 "wasm-bindgen-macro",
 "wasm-bindgen-shared",
]

[[package]]
name = "wasm-bindgen-macro"
version = "0.2.127"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77775f8f3f7217702089053b94958f8f54061a3f663417df76e19cbdcca29bc1"
dependencies = [
 "quote",
 "wasm-bindgen-macro-support",
]

[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.127"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e11d33f857dc2fb11b8bc75aee111aa9cbeb12cd9f25efd3d4c2a3dd4e235284"
dependencies = [
 "bumpalo",
 "proc-macro2",
 "quote",
 "syn",
 "wasm-bindgen-shared",
]

[[package]]
name = "wasm-bindgen-shared"
version = "0.2.127"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ef64dbcc55df09c7e5a46182d181c2cfa3e925f3da937ea764728b4bbb9dcbf"
dependencies = [
 "unicode-ident",
]
Cargo.toml
[package]
name = "sample-js-sys"
version = "1.0.0"
edition = "2021"
publish = false

[dependencies]
js-sys = "=0.3.104"

[[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/js-sys@0.3.104
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:cargo/js-sys@0.3.104

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:e9262b00e455604515b551749a73d9ef95b74fd620417b5ff4a9efcd4437d9ac","contract":["Number constants MAX_SAFE_INTEGER and MIN_SAFE_INTEGER define 53-bit integer boundaries","Number constants EPSILON, MAX_VALUE, and MIN_VALUE define float precision limits","Number constants NAN, POSITIVE_INFINITY, and NEGATIVE_INFINITY represent special float values","Number::try_from rejects integers exceeding safe bounds with TryFromIntError","TryFromIntError implements Display formatting and std::error::Error"],"goal":"verify pkg:cargo/js-sys@0.3.104","kind":"HOW","packages":["pkg:cargo/js-sys@0.3.104"],"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/js-sys@0.3.104"],"schemaVersion":1,"subject":"pkg:cargo/js-sys@0.3.104","verifierAdapter":"cargo@1"}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:cargo/js-sys@0.3.104",
  "kind": "HOW",
  "packages": [
    "pkg:cargo/js-sys@0.3.104"
  ]
}
src/lib.rs
//! Clean-room verification sample for js-sys.

pub use js_sys::*;
test/contract.rs
use core::convert::TryFrom;
use js_sys::{Number, TryFromIntError};

fn main() {
    // 1. Number constants MAX_SAFE_INTEGER and MIN_SAFE_INTEGER define 53-bit integer boundaries
    assert_eq!(Number::MAX_SAFE_INTEGER, 9007199254740991.0);
    assert_eq!(Number::MAX_SAFE_INTEGER, ((1u64 << 53) - 1) as f64);
    assert_eq!(Number::MIN_SAFE_INTEGER, -9007199254740991.0);
    assert_eq!(Number::MIN_SAFE_INTEGER, -(((1u64 << 53) - 1) as f64));

    // 2. Number constants EPSILON, MAX_VALUE, and MIN_VALUE define float precision limits
    assert_eq!(Number::EPSILON, f64::EPSILON);
    assert_eq!(Number::MAX_VALUE, f64::MAX);
    assert_eq!(Number::MIN_VALUE, 5E-324);

    // 3. Number constants NAN, POSITIVE_INFINITY, and NEGATIVE_INFINITY represent special float values
    assert!(Number::NAN.is_nan());
    assert_eq!(Number::POSITIVE_INFINITY, f64::INFINITY);
    assert_eq!(Number::NEGATIVE_INFINITY, f64::NEG_INFINITY);

    // 4. Number::try_from rejects integers exceeding safe bounds with TryFromIntError
    let max_i64_res: Result<Number, TryFromIntError> = Number::try_from(i64::MAX);
    assert!(max_i64_res.is_err());
    let min_i64_res: Result<Number, TryFromIntError> = Number::try_from(i64::MIN);
    assert!(min_i64_res.is_err());
    let max_u64_res: Result<Number, TryFromIntError> = Number::try_from(u64::MAX);
    assert!(max_u64_res.is_err());

    let max_i128_res: Result<Number, TryFromIntError> = Number::try_from(i128::MAX);
    assert!(max_i128_res.is_err());
    let min_i128_res: Result<Number, TryFromIntError> = Number::try_from(i128::MIN);
    assert!(min_i128_res.is_err());
    let max_u128_res: Result<Number, TryFromIntError> = Number::try_from(u128::MAX);
    assert!(max_u128_res.is_err());

    // 5. TryFromIntError implements Display formatting and std::error::Error
    let err = max_i64_res.unwrap_err();
    let err_clone = err;
    assert_eq!(err, err_clone);
    assert_eq!(format!("{err}"), "out of range integral type conversion attempted");
    assert_eq!(format!("{err:?}"), "TryFromIntError(())");
    let err_dyn: &dyn std::error::Error = &err;
    assert_eq!(err_dyn.to_string(), "out of range integral type conversion attempted");

    println!("All js-sys contract assertions passed successfully.");
}

原始种子者

匿名