Ejemplo
zerovec 0.11.6: zerovec::ZeroSlice
Muestra verificada para cargo zerovec 0.11.6: zerovec::ZeroSlice. El contrato se ejecutó en rust 1 · linux alpine/x64 · docker y pasó.
sha256:22a0b188ef591b46ce28ea8dc28b2c23bb99026c425849b3b45150de758cc56f
Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido.
Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas.
MIT-0
Evidencia de ejecución
El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.
- Base de evidencia
- Contrato firmado aprobado
- Recibos de verificación
- 1
- Claves de firma que lo compilaron
- 1
Entorno declarado
linux · alpine · musl x64 cargo
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| 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-21 |
Caso
HOW- Objetivo
- verify zerovec::ZeroSlice in pkg:cargo/zerovec@0.11.6
- Paquetes
- Símbolos
-
- zerovec::ZeroSlice
- Creado
- 2026-09-21T11:24:27Z
Contrato
- ZeroSlice::new_empty returns an empty slice with zero length
- ZeroSlice::parse_bytes parses valid little-endian byte slice into ZeroSlice
- ZeroSlice::as_bytes returns original underlying bytes
- ZeroSlice::from_ule_slice constructs ZeroSlice from unaligned little-endian array
- ZeroSlice::binary_search finds matching elements and insertion points
- ZeroSlice::as_zerovec converts ZeroSlice to borrowed ZeroVec
- ZeroSlice::parse_bytes returns error for invalid byte slice length
Archivos
- Cargo.lock
- Cargo.toml
- NOTES.md
- PROMPT.md
- csx.json
- spec.json
- src/lib.rs
- test/contract.rs
Código fuente
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "sample-zerovec"
version = "1.0.0"
dependencies = [
"zerovec",
]
[[package]]
name = "zerofrom"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272"
[[package]]
name = "zerovec"
version = "0.11.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90f911cbc359ab6af17377d242225f4d75119aec87ea711a880987b18cd7b239"
dependencies = [
"zerofrom",
]
[package]
name = "sample-zerovec"
version = "1.0.0"
edition = "2021"
publish = false
[dependencies]
zerovec = "=0.11.6"
[[bin]]
name = "contract"
path = "test/contract.rs"
# zerovec 0.11.6 ZeroSlice API Contracts
## What `search_known_solution` answered
`search_known_solution` returned NO_SAFE_MATCH for zerovec::ZeroSlice in pkg:cargo/zerovec@0.11.6.
## What a model would have written instead
A model may attempt to call `ZeroSlice::try_from_bytes` (which appears in older ICU4X docs but is not a method on `ZeroSlice`), use unaligned pointer casts directly without going through `from_ule_slice` or `parse_bytes`, or assume `ZeroSlice` allocates memory instead of functioning as a zero-copy dynamically-sized type over ULE slices.
## How the wrong version fails
Calling `ZeroSlice::try_from_bytes` causes a compile error (E0599: no function or associated item named `try_from_bytes` found for struct `ZeroSlice`). Using `parse_bytes` and `from_ule_slice` correctly validates and constructs byte-aligned zero-copy slices offline.
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 zerovec::ZeroSlice in pkg:cargo/zerovec@0.11.6
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/zerovec@0.11.6
Demonstrate these symbols/APIs:
- zerovec::ZeroSlice
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:6d6daf6a88e1897876e7ba29af37b41e9373617260a9d789f2622d191c63d939","contract":["ZeroSlice::new_empty returns an empty slice with zero length","ZeroSlice::parse_bytes parses valid little-endian byte slice into ZeroSlice","ZeroSlice::as_bytes returns original underlying bytes","ZeroSlice::from_ule_slice constructs ZeroSlice from unaligned little-endian array","ZeroSlice::binary_search finds matching elements and insertion points","ZeroSlice::as_zerovec converts ZeroSlice to borrowed ZeroVec","ZeroSlice::parse_bytes returns error for invalid byte slice length"],"goal":"verify zerovec::ZeroSlice in pkg:cargo/zerovec@0.11.6","kind":"HOW","packages":["pkg:cargo/zerovec@0.11.6"],"schemaVersion":1,"symbols":["zerovec::ZeroSlice"]},"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/zerovec@0.11.6"],"schemaVersion":1,"subject":"pkg:cargo/zerovec@0.11.6","symbols":["zerovec::ZeroSlice"],"verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify zerovec::ZeroSlice in pkg:cargo/zerovec@0.11.6",
"kind": "HOW",
"packages": [
"pkg:cargo/zerovec@0.11.6"
],
"symbols": [
"zerovec::ZeroSlice"
]
}
//! Clean-room verification sample for zerovec::ZeroSlice.
pub use zerovec::ZeroSlice;
use zerovec::ule::AsULE;
use zerovec::ZeroSlice;
const CONST_SLICE: &ZeroSlice<u16> =
ZeroSlice::<u16>::from_ule_slice(&<u16 as AsULE>::ULE::from_array([
10, 20, 30, 40,
]));
fn main() {
// 1. ZeroSlice::new_empty returns an empty slice with zero length
let empty = ZeroSlice::<u32>::new_empty();
assert_eq!(empty.len(), 0);
assert!(empty.is_empty());
assert_eq!(empty.first(), None);
assert_eq!(empty.last(), None);
assert_eq!(empty.get(0), None);
// 2. ZeroSlice::parse_bytes parses valid little-endian byte slice into ZeroSlice
let bytes: &[u8] = &[
100, 0, 0, 0,
200, 0, 0, 0,
44, 1, 0, 0,
];
let slice = ZeroSlice::<u32>::parse_bytes(bytes).expect("valid byte slice for u32 ULE");
assert_eq!(slice.len(), 3);
assert!(!slice.is_empty());
assert_eq!(slice.get(0), Some(100));
assert_eq!(slice.get(1), Some(200));
assert_eq!(slice.get(2), Some(300));
assert_eq!(slice.get(3), None);
assert_eq!(slice.first(), Some(100));
assert_eq!(slice.last(), Some(300));
// 3. ZeroSlice::as_bytes returns original underlying bytes
assert_eq!(slice.as_bytes(), bytes);
// 4. ZeroSlice::from_ule_slice constructs ZeroSlice from unaligned little-endian array
assert_eq!(CONST_SLICE.len(), 4);
assert_eq!(CONST_SLICE.get(0), Some(10));
assert_eq!(CONST_SLICE.get(1), Some(20));
assert_eq!(CONST_SLICE.get(2), Some(30));
assert_eq!(CONST_SLICE.get(3), Some(40));
// 5. ZeroSlice::binary_search finds matching elements and insertion points
assert_eq!(slice.binary_search(&200), Ok(1));
assert_eq!(slice.binary_search(&250), Err(2));
assert_eq!(slice.binary_search(&50), Err(0));
assert_eq!(slice.binary_search(&400), Err(3));
// 6. ZeroSlice::as_zerovec converts ZeroSlice to borrowed ZeroVec
let zv = slice.as_zerovec();
assert_eq!(zv.len(), 3);
assert_eq!(zv.get(1), Some(200));
// 7. ZeroSlice::parse_bytes returns error for invalid byte slice length
let invalid_bytes: &[u8] = &[1, 2, 3];
assert!(ZeroSlice::<u32>::parse_bytes(invalid_bytes).is_err());
println!("All zerovec::ZeroSlice contract assertions passed successfully.");
}
Seeder de origen
anónimo