Exemplo
tinyvec_macros 0.1.1
Amostra verificada para cargo tinyvec_macros 0.1.1. O contrato rodou em rust 1 · linux alpine/x64 · docker e passou: tinyvec_macros::impl_mirrored! generates…
sha256:7b8edb2eba7a28defce8f86e068807951ac843fe9b807b9189542d861d0a3787
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 1
- Chaves de assinatura que o compilaram
- 1
Ambiente declarado
linux x64 cargo
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| 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-11-22 |
Caso
HOW- Objetivo
- verify pkg:cargo/tinyvec_macros@0.1.1
- Pacotes
- Criado
- 2026-11-22T01:22:39Z
Contrato
- tinyvec_macros::impl_mirrored! generates forwarding methods matching Inline and Heap variants for explicit self: &Self receivers with zero and multiple arguments
- tinyvec_macros::impl_mirrored! generates forwarding methods for self: &mut Self receivers both with arguments (push) and with omitted unit return types (clear)
- tinyvec_macros::impl_mirrored! generates forwarding methods for owned self: Self receivers and preserves visibility modifiers (pub, pub(crate)) and item attributes
Arquivos
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- src/lib.rs
- tests/contract.rs
Código-fonte
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "sample-tinyvec-macros"
version = "0.1.0"
dependencies = [
"tinyvec_macros",
]
[[package]]
name = "tinyvec_macros"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[package]
name = "sample-tinyvec-macros"
version = "0.1.0"
edition = "2021"
[dependencies]
tinyvec_macros = "=0.1.1"
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/tinyvec_macros@0.1.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/tinyvec_macros@0.1.1
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
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:1ba39410104d09c64ea986cb947a47d7358cfc3deb76652087618c9fc2afa5d2","contract":["tinyvec_macros::impl_mirrored! generates forwarding methods matching Inline and Heap variants for explicit self: \u0026Self receivers with zero and multiple arguments","tinyvec_macros::impl_mirrored! generates forwarding methods for self: \u0026mut Self receivers both with arguments (push) and with omitted unit return types (clear)","tinyvec_macros::impl_mirrored! generates forwarding methods for owned self: Self receivers and preserves visibility modifiers (pub, pub(crate)) and item attributes"],"goal":"verify pkg:cargo/tinyvec_macros@0.1.1","kind":"HOW","packages":["pkg:cargo/tinyvec_macros@0.1.1"],"schemaVersion":1},"contractCommand":["cargo","test","--offline"],"environment":{"arch":"x64","ecosystem":"cargo","os":"linux","packageManager":"cargo","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/tinyvec_macros@0.1.1"],"schemaVersion":1,"subject":"pkg:cargo/tinyvec_macros@0.1.1","verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify pkg:cargo/tinyvec_macros@0.1.1",
"kind": "HOW",
"packages": [
"pkg:cargo/tinyvec_macros@0.1.1"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
use tinyvec_macros::impl_mirrored;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct InlineBuf {
data: [i32; 4],
len: usize,
}
impl InlineBuf {
pub fn new() -> Self {
Self {
data: [0; 4],
len: 0,
}
}
pub fn len(&self) -> usize {
self.len
}
pub fn is_empty(&self) -> bool {
self.len == 0
}
pub fn push(&mut self, value: i32) {
assert!(self.len < self.data.len(), "inline capacity exceeded");
self.data[self.len] = value;
self.len += 1;
}
pub fn get_or(&self, index: usize, fallback: i32) -> i32 {
if index < self.len {
self.data[index]
} else {
fallback
}
}
pub fn clear(&mut self) {
self.len = 0;
}
pub fn sum_with_offset(&self, offset: i32) -> i32 {
self.data[..self.len].iter().copied().sum::<i32>() + offset
}
pub fn into_vec(self) -> Vec<i32> {
self.data[..self.len].to_vec()
}
}
impl Default for InlineBuf {
fn default() -> Self {
Self::new()
}
}
#[derive(Debug, Clone, PartialEq, Eq, Default)]
pub struct HeapBuf {
data: Vec<i32>,
}
impl HeapBuf {
pub fn new() -> Self {
Self { data: Vec::new() }
}
pub fn len(&self) -> usize {
self.data.len()
}
pub fn is_empty(&self) -> bool {
self.data.is_empty()
}
pub fn push(&mut self, value: i32) {
self.data.push(value);
}
pub fn get_or(&self, index: usize, fallback: i32) -> i32 {
self.data.get(index).copied().unwrap_or(fallback)
}
pub fn clear(&mut self) {
self.data.clear();
}
pub fn sum_with_offset(&self, offset: i32) -> i32 {
self.data.iter().copied().sum::<i32>() + offset
}
pub fn into_vec(self) -> Vec<i32> {
self.data
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum MirroredBuf {
Inline(InlineBuf),
Heap(HeapBuf),
}
impl MirroredBuf {
pub fn new_inline() -> Self {
Self::Inline(InlineBuf::new())
}
pub fn new_heap() -> Self {
Self::Heap(HeapBuf::new())
}
impl_mirrored! {
type Mirror = MirroredBuf;
/// Returns the number of elements stored in either variant.
pub fn len(self: &Self) -> usize;
/// Returns true when the active backing buffer has zero elements.
pub fn is_empty(self: &Self) -> bool;
/// Appends a value to the active backing buffer.
pub fn push(self: &mut Self, value: i32);
/// Reads an element at `index` or returns `fallback` when out of bounds.
pub fn get_or(self: &Self, index: usize, fallback: i32) -> i32;
/// Empties the active backing buffer without returning a value.
pub fn clear(self: &mut Self);
/// Computes the sum of stored values plus an offset.
#[allow(dead_code)]
pub(crate) fn sum_with_offset(self: &Self, offset: i32) -> i32;
/// Consumes the mirrored enum and returns its elements as a `Vec<i32>`.
pub fn into_vec(self: Self) -> Vec<i32>;
}
pub fn total_plus(&self, offset: i32) -> i32 {
self.sum_with_offset(offset)
}
}
use sample_tinyvec_macros::MirroredBuf;
#[test]
fn inline_variant_dispatches_shared_mut_and_owned_methods() {
let mut buf = MirroredBuf::new_inline();
assert!(buf.is_empty());
assert_eq!(buf.len(), 0);
assert_eq!(buf.get_or(0, -1), -1);
buf.push(10);
buf.push(20);
buf.push(30);
assert!(!buf.is_empty());
assert_eq!(buf.len(), 3);
assert_eq!(buf.get_or(0, -1), 10);
assert_eq!(buf.get_or(2, -1), 30);
assert_eq!(buf.get_or(3, -1), -1);
assert_eq!(buf.total_plus(5), 65);
let cloned = buf.clone();
assert_eq!(cloned.into_vec(), vec![10, 20, 30]);
buf.clear();
assert!(buf.is_empty());
assert_eq!(buf.len(), 0);
assert_eq!(buf.into_vec(), Vec::<i32>::new());
}
#[test]
fn heap_variant_dispatches_shared_mut_and_owned_methods() {
let mut buf = MirroredBuf::new_heap();
assert!(buf.is_empty());
assert_eq!(buf.len(), 0);
assert_eq!(buf.get_or(0, -9), -9);
for v in [1, 2, 3, 4, 5] {
buf.push(v);
}
assert!(!buf.is_empty());
assert_eq!(buf.len(), 5);
assert_eq!(buf.get_or(4, -9), 5);
assert_eq!(buf.get_or(5, -9), -9);
assert_eq!(buf.total_plus(10), 25);
let cloned = buf.clone();
assert_eq!(cloned.into_vec(), vec![1, 2, 3, 4, 5]);
buf.clear();
assert!(buf.is_empty());
assert_eq!(buf.len(), 0);
assert_eq!(buf.into_vec(), Vec::<i32>::new());
}
Seeder de origem
anônimo