Exemple
deranged 0.5.9: deranged::OptionRangedI32
Échantillon vérifié pour cargo deranged 0.5.9: deranged::OptionRangedI32. Le contrat s'est exécuté sur rust 1 · linux alpine/x64 · docker et a réussi.
sha256:8f4acf3b09a8ef825517f19d4fb65416b8157674ce02c2c0dbbeff4510ee66ab
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 · 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-10-31 |
Cas
HOW- Objectif
- verify deranged::OptionRangedI32 in pkg:cargo/deranged@0.5.9
- Paquets
- Symboles
-
- deranged::OptionRangedI32
- Créé
- 2026-10-31T01:45:51Z
Contrat
- OptionRangedI32::Some wraps a valid RangedI32 and reports is_some() == true, get() == Some(ranged), and get_primitive() == Some(i32)
- OptionRangedI32::None and Default::default() represent an absent value with is_none() == true and get_primitive() == None
- OptionRangedI32<MIN, MAX> uses niche optimization and has the same size in memory as i32
Fichiers
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- src/lib.rs
- src/main.rs
- test/contract.rs
Code source
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "deranged"
version = "0.5.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e9de72ce2ad1f90dc62fa25f0f430ef85eb4b0d8fa0be4f30373bc40a21d28e"
[[package]]
name = "sample"
version = "0.1.0"
dependencies = [
"deranged",
]
[package]
name = "sample"
version = "0.1.0"
edition = "2021"
[dependencies]
deranged = "0.5.9"
[[test]]
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 deranged::OptionRangedI32 in pkg:cargo/deranged@0.5.9
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/deranged@0.5.9
Demonstrate these symbols/APIs:
- deranged::OptionRangedI32
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:f3c2e0170425ab18d2e1bbe5fd6995cc6cdc569a244fe957042f4eb44f3f2c8f","contract":["OptionRangedI32::Some wraps a valid RangedI32 and reports is_some() == true, get() == Some(ranged), and get_primitive() == Some(i32)","OptionRangedI32::None and Default::default() represent an absent value with is_none() == true and get_primitive() == None","OptionRangedI32\u003cMIN, MAX\u003e uses niche optimization and has the same size in memory as i32"],"goal":"verify deranged::OptionRangedI32 in pkg:cargo/deranged@0.5.9","kind":"HOW","packages":["pkg:cargo/deranged@0.5.9"],"schemaVersion":1,"symbols":["deranged::OptionRangedI32"]},"contractCommand":["cargo","test","--offline"],"environment":{"arch":"x64","ecosystem":"cargo","libc":"musl","os":"linux","packageManager":"cargo","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/deranged@0.5.9"],"schemaVersion":1,"subject":"pkg:cargo/deranged@0.5.9","symbols":["deranged::OptionRangedI32"],"verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify deranged::OptionRangedI32 in pkg:cargo/deranged@0.5.9",
"kind": "HOW",
"packages": [
"pkg:cargo/deranged@0.5.9"
],
"symbols": [
"deranged::OptionRangedI32"
]
}
use deranged::{OptionRangedI32, RangedI32};
pub fn wrap_optional_day(value: Option<i32>) -> Result<OptionRangedI32<1, 31>, &'static str> {
match value {
Some(v) => {
let ranged = RangedI32::<1, 31>::new(v).ok_or("out of range")?;
Ok(OptionRangedI32::Some(ranged))
}
None => Ok(OptionRangedI32::None),
}
}
pub fn unwrap_optional_day(opt: OptionRangedI32<1, 31>) -> Option<i32> {
opt.get_primitive()
}
use deranged::{OptionRangedI32, RangedI32};
use sample::{unwrap_optional_day, wrap_optional_day};
fn main() {
let some_day = wrap_optional_day(Some(15)).expect("15 is in range 1..=31");
assert!(some_day.is_some());
assert!(!some_day.is_none());
assert_eq!(some_day.get(), Some(RangedI32::<1, 31>::new_static::<15>()));
assert_eq!(unwrap_optional_day(some_day), Some(15));
assert_eq!(some_day.get_primitive_without_hint(), Some(15));
let none_day = wrap_optional_day(None).expect("None is valid");
assert!(none_day.is_none());
assert!(!none_day.is_some());
assert_eq!(none_day.get(), None);
assert_eq!(unwrap_optional_day(none_day), None);
assert_eq!(none_day, OptionRangedI32::<1, 31>::default());
assert!(wrap_optional_day(Some(0)).is_err());
assert!(wrap_optional_day(Some(32)).is_err());
assert_eq!(
core::mem::size_of::<OptionRangedI32<1, 31>>(),
core::mem::size_of::<i32>()
);
}
use deranged::{OptionRangedI32, RangedI32};
use sample::{unwrap_optional_day, wrap_optional_day};
#[test]
fn contract_option_ranged_i32() {
let some_day = wrap_optional_day(Some(15)).expect("15 is in range 1..=31");
assert!(some_day.is_some());
assert!(!some_day.is_none());
assert_eq!(some_day.get(), Some(RangedI32::<1, 31>::new_static::<15>()));
assert_eq!(unwrap_optional_day(some_day), Some(15));
assert_eq!(some_day.get_primitive_without_hint(), Some(15));
let none_day = wrap_optional_day(None).expect("None is valid");
assert!(none_day.is_none());
assert!(!none_day.is_some());
assert_eq!(none_day.get(), None);
assert_eq!(unwrap_optional_day(none_day), None);
assert_eq!(none_day, OptionRangedI32::<1, 31>::default());
assert!(wrap_optional_day(Some(0)).is_err());
assert!(wrap_optional_day(Some(32)).is_err());
assert_eq!(
core::mem::size_of::<OptionRangedI32<1, 31>>(),
core::mem::size_of::<i32>()
);
}
Seeder d'origine
anonyme