CodeSampleX

Beispiel

syn 3.0.3: syn::GenericArgument

Verifiziertes Beispiel für cargo syn 3.0.3: syn::GenericArgument. Der Vertrag lief auf rust 1 · linux alpine/x64 · docker und bestand.

sha256:0213bb11dbd4d7ac7c446ef54a9b422fbb380220a46a932ba9dab272faacf436

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung linux · alpine · musl x64 cargo

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
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-10

Fall

HOW
Ziel
verify syn::GenericArgument in pkg:cargo/syn@3.0.3
Pakete
Symbole
  • syn::GenericArgument
Erstellt
2026-10-10T05:59:18Z

Contract

  1. syn::parse_str parses lifetime arguments into GenericArgument::Lifetime
  2. syn::parse_str parses type arguments into GenericArgument::Type
  3. syn::parse_str parses integer literal const arguments into GenericArgument::Const
  4. syn::parse_str parses boolean literal const arguments into GenericArgument::Const
  5. syn::parse_str parses associated type bindings into GenericArgument::AssocType
  6. syn::parse_str parses associated const bindings into GenericArgument::AssocConst
  7. syn::parse_str parses trait bound constraints into GenericArgument::Constraint
  8. syn::parse_str extracts GenericArgument elements from angle bracketed path arguments
  9. syn::parse_str rejects invalid generic argument syntax with a parse error

Dateien

  • Cargo.lock
  • Cargo.toml
  • PROMPT.md
  • csx.json
  • spec.json
  • src/lib.rs
  • test/contract.rs

Quellartefakt herunterladen (tar.gz)

Quelltext

Cargo.lock
# 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 = "sample-syn"
version = "1.0.0"
dependencies = [
 "syn",
]

[[package]]
name = "syn"
version = "3.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53e9bae58849f64dfa4f5d5ae372c8341f7305f82a3868709269343628b659a3"
dependencies = [
 "proc-macro2",
 "unicode-ident",
]

[[package]]
name = "unicode-ident"
version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954"
Cargo.toml
[package]
name = "sample-syn"
version = "1.0.0"
edition = "2021"
publish = false

[dependencies]
syn = { version = "=3.0.3", default-features = false, features = ["derive", "parsing"] }

[[bin]]
name = "contract"
path = "test/contract.rs"
PROMPT.md
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 syn::GenericArgument in pkg:cargo/syn@3.0.3
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:cargo/syn@3.0.3
Demonstrate these symbols/APIs:
  - syn::GenericArgument

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.
csx.json
{"case":{"caseId":"case:sha256:f179ae8549170cbb44e7efa4f967b75bf7583a4f5f9e52b405cb89f81654d05e","contract":["syn::parse_str parses lifetime arguments into GenericArgument::Lifetime","syn::parse_str parses type arguments into GenericArgument::Type","syn::parse_str parses integer literal const arguments into GenericArgument::Const","syn::parse_str parses boolean literal const arguments into GenericArgument::Const","syn::parse_str parses associated type bindings into GenericArgument::AssocType","syn::parse_str parses associated const bindings into GenericArgument::AssocConst","syn::parse_str parses trait bound constraints into GenericArgument::Constraint","syn::parse_str extracts GenericArgument elements from angle bracketed path arguments","syn::parse_str rejects invalid generic argument syntax with a parse error"],"goal":"verify syn::GenericArgument in pkg:cargo/syn@3.0.3","kind":"HOW","packages":["pkg:cargo/syn@3.0.3"],"schemaVersion":1,"symbols":["syn::GenericArgument"]},"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/syn@3.0.3"],"schemaVersion":1,"subject":"pkg:cargo/syn@3.0.3","symbols":["syn::GenericArgument"],"verifierAdapter":"cargo@1"}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify syn::GenericArgument in pkg:cargo/syn@3.0.3",
  "kind": "HOW",
  "packages": [
    "pkg:cargo/syn@3.0.3"
  ],
  "symbols": [
    "syn::GenericArgument"
  ]
}
src/lib.rs
//! Clean-room verification sample for syn::GenericArgument.

pub use syn::*;
test/contract.rs
use syn::{
    parse_str, AssocConst, AssocType, Constraint, Expr, GenericArgument, Lifetime, Lit,
    PathArguments, Type,
};

fn main() {
    // 1. syn::parse_str parses lifetime arguments into GenericArgument::Lifetime
    let lifetime_arg: GenericArgument = parse_str("'a").expect("lifetime argument");
    match &lifetime_arg {
        GenericArgument::Lifetime(Lifetime { ident, .. }) => {
            assert_eq!(ident.to_string(), "a");
        }
        _ => panic!("expected GenericArgument::Lifetime"),
    }

    // 2. syn::parse_str parses type arguments into GenericArgument::Type
    let type_arg: GenericArgument = parse_str("String").expect("type argument");
    match &type_arg {
        GenericArgument::Type(Type::Path(type_path)) => {
            assert_eq!(type_path.path.segments.last().unwrap().ident.to_string(), "String");
        }
        _ => panic!("expected GenericArgument::Type"),
    }

    // 3. syn::parse_str parses integer literal const arguments into GenericArgument::Const
    let const_int_arg: GenericArgument = parse_str("42").expect("const int argument");
    match &const_int_arg {
        GenericArgument::Const(Expr::Lit(expr_lit)) => {
            match &expr_lit.lit {
                Lit::Int(lit_int) => assert_eq!(lit_int.base10_parse::<u32>().unwrap(), 42),
                _ => panic!("expected Lit::Int"),
            }
        }
        _ => panic!("expected GenericArgument::Const with Expr::Lit"),
    }

    // 4. syn::parse_str parses boolean literal const arguments into GenericArgument::Const
    let const_bool_arg: GenericArgument = parse_str("true").expect("const bool argument");
    match &const_bool_arg {
        GenericArgument::Const(Expr::Lit(expr_lit)) => {
            match &expr_lit.lit {
                Lit::Bool(lit_bool) => assert!(lit_bool.value),
                _ => panic!("expected Lit::Bool"),
            }
        }
        _ => panic!("expected GenericArgument::Const with Expr::Lit"),
    }

    // 5. syn::parse_str parses associated type bindings into GenericArgument::AssocType
    let assoc_type_arg: GenericArgument = parse_str("Item = u32").expect("associated type argument");
    match &assoc_type_arg {
        GenericArgument::AssocType(AssocType { ident, ty, .. }) => {
            assert_eq!(ident.to_string(), "Item");
            assert!(matches!(ty, Type::Path(_)));
        }
        _ => panic!("expected GenericArgument::AssocType"),
    }

    // 6. syn::parse_str parses associated const bindings into GenericArgument::AssocConst
    let assoc_const_arg: GenericArgument = parse_str("N = 10").expect("associated const argument");
    match &assoc_const_arg {
        GenericArgument::AssocConst(AssocConst { ident, value, .. }) => {
            assert_eq!(ident.to_string(), "N");
            assert!(matches!(value, Expr::Lit(_)));
        }
        _ => panic!("expected GenericArgument::AssocConst"),
    }

    // 7. syn::parse_str parses trait bound constraints into GenericArgument::Constraint
    let constraint_arg: GenericArgument = parse_str("Item: Display").expect("constraint argument");
    match &constraint_arg {
        GenericArgument::Constraint(Constraint { ident, bounds, .. }) => {
            assert_eq!(ident.to_string(), "Item");
            assert_eq!(bounds.len(), 1);
        }
        _ => panic!("expected GenericArgument::Constraint"),
    }

    // 8. syn::parse_str extracts GenericArgument elements from angle bracketed path arguments
    let path: syn::Path = parse_str("std::result::Result<T, E>").expect("path with generic arguments");
    match &path.segments.last().unwrap().arguments {
        PathArguments::AngleBracketed(args) => {
            assert_eq!(args.args.len(), 2);
            assert!(matches!(args.args[0], GenericArgument::Type(_)));
            assert!(matches!(args.args[1], GenericArgument::Type(_)));
        }
        _ => panic!("expected AngleBracketed arguments"),
    }

    // 9. syn::parse_str rejects invalid generic argument syntax with a parse error
    let invalid = parse_str::<GenericArgument>("fn(invalid syntax !!!");
    assert!(invalid.is_err());

    println!("All syn::GenericArgument contract assertions passed successfully.");
}

Ursprungs-Seeder

anonym