Пример
quote 1.0.47
Проверенный пример — cargo quote 1.0.47. Контракт выполнен на rust 1 · linux alpine/x64 · docker и пройден: quote::quote! interpolates variables and produces…
sha256:1071b9984652b2795c13d55194eb6e451acf0fb15f4b220f78cca43e8bd891bc
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
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-14 |
Кейс
HOW- Цель
- verify pkg:cargo/quote@1.0.47
- Пакеты
- Создан
- 2026-09-14T06:44:09Z
Контракт
- quote::quote! interpolates variables and produces a TokenStream
- quote::quote! supports repeated sequences with repetition syntax
- quote::format_ident! constructs formatted identifiers and raw identifiers
- quote::ToTokens converts values into token streams
Файлы
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- src/lib.rs
- test/contract.rs
Исходный код
# 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 = "quote-verify"
version = "0.1.0"
dependencies = [
"quote",
]
[[package]]
name = "unicode-ident"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
[package]
name = "quote-verify"
version = "0.1.0"
edition = "2021"
publish = false
[lib]
path = "src/lib.rs"
[[bin]]
name = "contract"
path = "test/contract.rs"
[dependencies]
quote = "=1.0.47"
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/quote@1.0.47
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/quote@1.0.47
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:ab8a2f218a159823665f65db49f41c1f3fbf8d96386790d5b3ffcaac5dd36cbc","contract":["quote::quote! interpolates variables and produces a TokenStream","quote::quote! supports repeated sequences with repetition syntax","quote::format_ident! constructs formatted identifiers and raw identifiers","quote::ToTokens converts values into token streams"],"goal":"verify pkg:cargo/quote@1.0.47","kind":"HOW","packages":["pkg:cargo/quote@1.0.47"],"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/quote@1.0.47"],"schemaVersion":1,"subject":"pkg:cargo/quote@1.0.47","verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify pkg:cargo/quote@1.0.47",
"kind": "HOW",
"packages": [
"pkg:cargo/quote@1.0.47"
]
}
use quote::{format_ident, quote, ToTokens};
/// Generates a function definition TokenStream using quote! macro.
pub fn generate_function(fn_name: &str, return_value: i32) -> String {
let name = format_ident!("{}", fn_name);
let tokens = quote! {
fn #name() -> i32 {
#return_value
}
};
tokens.to_string()
}
/// Generates a struct with fields using repeated interpolation in quote! macro.
pub fn generate_struct(struct_name: &str, field_names: &[&str], field_types: &[&str]) -> String {
let struct_id = format_ident!("{}", struct_name);
let field_ids: Vec<_> = field_names.iter().map(|f| format_ident!("{}", f)).collect();
let type_ids: Vec<_> = field_types.iter().map(|t| format_ident!("{}", t)).collect();
let tokens = quote! {
struct #struct_id {
#(pub #field_ids: #type_ids,)*
}
};
tokens.to_string()
}
/// Demonstrates ToTokens trait by converting a value to TokenStream string.
pub fn value_to_tokens<T: ToTokens>(val: &T) -> String {
val.to_token_stream().to_string()
}
/// Demonstrates format_ident! with raw identifiers.
pub fn make_raw_identifier(name: &str) -> String {
let ident = format_ident!("r#{}", name);
ident.to_string()
}
use quote::{format_ident, quote};
use quote_verify::{generate_function, generate_struct, make_raw_identifier, value_to_tokens};
fn main() {
// 1. quote::quote! interpolates variables and produces a TokenStream
let fn_str = generate_function("compute_answer", 42);
assert!(fn_str.contains("fn compute_answer () -> i32"), "must contain function signature, got: {fn_str}");
assert!(fn_str.contains("42"), "must contain return value 42, got: {fn_str}");
// Direct quote! interpolation
let greeting = "hello";
let count = 3usize;
let direct_tokens = quote! {
let msg = #greeting;
let c = #count;
};
let direct_str = direct_tokens.to_string();
assert!(direct_str.contains("\"hello\""), "string literal must be quoted, got: {direct_str}");
assert!(direct_str.contains("3usize"), "usize must have suffix, got: {direct_str}");
// 2. quote::quote! supports repeated sequences with repetition syntax
let struct_str = generate_struct("Point", &["x", "y"], &["f64", "f64"]);
assert!(struct_str.contains("struct Point"), "must contain struct name, got: {struct_str}");
assert!(struct_str.contains("pub x : f64"), "must contain pub x : f64, got: {struct_str}");
assert!(struct_str.contains("pub y : f64"), "must contain pub y : f64, got: {struct_str}");
// Separated repetition
let numbers = vec![1i32, 2, 3, 4];
let list_tokens = quote! {
[ #( #numbers ),* ]
};
assert_eq!(list_tokens.to_string(), "[1i32 , 2i32 , 3i32 , 4i32]");
// 3. quote::format_ident! constructs formatted identifiers and raw identifiers
let formatted = format_ident!("my_variable_{}", 42usize);
assert_eq!(formatted.to_string(), "my_variable_42");
let raw = make_raw_identifier("type");
assert_eq!(raw, "r#type");
// 4. quote::ToTokens converts values into token streams
let num_tokens = value_to_tokens(&100u32);
assert_eq!(num_tokens, "100u32");
let bool_tokens = value_to_tokens(&true);
assert_eq!(bool_tokens, "true");
println!("Contract verification succeeded.");
}
Исходный сидер
аноним