Ejemplo
synstructure 0.14.0: synstructure
Muestra verificada para cargo synstructure 0.14.0: synstructure. El contrato se ejecutó en rust 1 · linux alpine/x64 · docker y pasó.
sha256:19d5be0c39c25ee222a5373c5722af6685c6f02d2e46465e2563c9eec9fa0f64
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 synstructure in pkg:cargo/synstructure@0.14.0
- Paquetes
- Símbolos
-
- synstructure
- Creado
- 2026-09-21T07:21:24Z
Contrato
- synstructure Structure creates structural representations of structs and enums from syn DeriveInput
- synstructure each generates pattern match arms executing expressions for each field binding
- synstructure fold aggregates field bindings within each variant into a combined expression
- synstructure bind_with customizes pattern destructuring binding style between Ref and Move
- synstructure filter selectively includes or excludes field bindings based on predicate
- synstructure gen_impl generates trait implementation blocks parameterized over the self type
Archivos
- Cargo.lock
- Cargo.toml
- 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 = "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 = "sample-synstructure"
version = "1.0.0"
dependencies = [
"proc-macro2",
"quote",
"syn",
"synstructure",
]
[[package]]
name = "syn"
version = "3.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8593e8e72159ed2257d083c7a454a85cbf854f37a0966d8d483aff8c8a3ebcee"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "synstructure"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "unicode-ident"
version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954"
[package]
name = "sample-synstructure"
version = "1.0.0"
edition = "2021"
publish = false
[dependencies]
synstructure = "=0.14.0"
syn = { version = "=3.0.6", features = ["derive", "parsing", "printing", "clone-impls", "extra-traits"] }
quote = "=1.0.47"
proc-macro2 = "=1.0.107"
[[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 synstructure in pkg:cargo/synstructure@0.14.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/synstructure@0.14.0
Demonstrate these symbols/APIs:
- synstructure
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:679a3d7b7380232bc09287652593261d1d59b401496ee69139acd5b6b6852940","contract":["synstructure Structure creates structural representations of structs and enums from syn DeriveInput","synstructure each generates pattern match arms executing expressions for each field binding","synstructure fold aggregates field bindings within each variant into a combined expression","synstructure bind_with customizes pattern destructuring binding style between Ref and Move","synstructure filter selectively includes or excludes field bindings based on predicate","synstructure gen_impl generates trait implementation blocks parameterized over the self type"],"goal":"verify synstructure in pkg:cargo/synstructure@0.14.0","kind":"HOW","packages":["pkg:cargo/synstructure@0.14.0"],"schemaVersion":1,"symbols":["synstructure"]},"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/synstructure@0.14.0"],"schemaVersion":1,"subject":"pkg:cargo/synstructure@0.14.0","symbols":["synstructure"],"verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify synstructure in pkg:cargo/synstructure@0.14.0",
"kind": "HOW",
"packages": [
"pkg:cargo/synstructure@0.14.0"
],
"symbols": [
"synstructure"
]
}
//! Clean-room verification sample for synstructure.
pub use synstructure::*;
use quote::quote;
use synstructure::{BindStyle, Structure};
fn main() {
// 1. synstructure Structure creates structural representations of structs and enums from syn DeriveInput
let enum_ast: syn::DeriveInput = syn::parse_str(
"enum Animal { Dog(String, u32), Cat { name: String, lives: u8 }, Fish }"
).expect("failed to parse enum AST");
let s_enum = Structure::new(&enum_ast);
assert_eq!(s_enum.variants().len(), 3);
assert_eq!(s_enum.variants()[0].ast().ident.to_string(), "Dog");
assert_eq!(s_enum.variants()[0].bindings().len(), 2);
assert_eq!(s_enum.variants()[1].ast().ident.to_string(), "Cat");
assert_eq!(s_enum.variants()[1].bindings().len(), 2);
assert_eq!(s_enum.variants()[2].ast().ident.to_string(), "Fish");
assert_eq!(s_enum.variants()[2].bindings().len(), 0);
let struct_ast: syn::DeriveInput = syn::parse_str(
"struct Point { x: f64, y: f64 }"
).expect("failed to parse struct AST");
let s_struct = Structure::new(&struct_ast);
assert_eq!(s_struct.variants().len(), 1);
assert_eq!(s_struct.variants()[0].bindings().len(), 2);
// 2. synstructure each generates pattern match arms executing expressions for each field binding
let s_each = s_enum.clone();
let each_tokens = s_each.each(|bi| {
quote! {
visited(#bi);
}
});
let each_str = each_tokens.to_string();
assert!(each_str.contains("Animal :: Dog (ref __binding_0 , ref __binding_1 ,) =>"));
assert!(each_str.contains("Animal :: Cat { name : ref __binding_0 , lives : ref __binding_1 , } =>"));
assert!(each_str.contains("Animal :: Fish => { }"));
assert!(each_str.contains("visited (__binding_0) ;"));
assert!(each_str.contains("visited (__binding_1) ;"));
// 3. synstructure fold aggregates field bindings within each variant into a combined expression
let s_fold = s_enum.clone();
let fold_tokens = s_fold.fold(quote!(0usize), |acc, bi| {
quote!(#acc + #bi.size())
});
let fold_str = fold_tokens.to_string();
assert!(fold_str.contains("0usize + __binding_0 . size () + __binding_1 . size ()"));
// 4. synstructure bind_with customizes pattern destructuring binding style between Ref and Move
let mut s_move = s_enum.clone();
s_move.bind_with(|_| BindStyle::Move);
let move_tokens = s_move.each(|bi| quote! { drop(#bi); });
let move_str = move_tokens.to_string();
assert!(move_str.contains("Animal :: Dog (__binding_0 , __binding_1 ,) =>"));
assert!(!move_str.contains("ref __binding_0"));
// 5. synstructure filter selectively includes or excludes field bindings based on predicate
let mut s_filter = s_enum.clone();
s_filter.filter(|bi| {
bi.ast().ident.as_ref().map_or(true, |id| id != "lives")
});
// Cat variant had 2 bindings (name, lives), now lives is filtered out
assert_eq!(s_filter.variants()[1].bindings().len(), 1);
assert_eq!(
s_filter.variants()[1].bindings()[0].ast().ident.as_ref().unwrap().to_string(),
"name"
);
assert!(s_filter.variants()[1].omitted_bindings());
// 6. synstructure gen_impl generates trait implementation blocks parameterized over the self type
let impl_tokens = s_enum.gen_impl(quote! {
gen impl MyTrait for @Self {
fn name(&self) -> &'static str {
"animal"
}
}
});
let impl_str = impl_tokens.to_string();
assert!(impl_str.contains("impl MyTrait for Animal"));
assert!(impl_str.contains("fn name (& self) -> & 'static str"));
println!("All synstructure contract assertions passed successfully.");
}
Seeder de origen
anónimo