CodeSampleX

Sample

syn 3.0.3: syn::ExprBinary

Verified sample for cargo syn 3.0.3: syn::ExprBinary. The contract ran on rust 1 · linux alpine/x64 · docker and passed: syn::parse_str parses binary…

sha256:d225b5fd6b461e6c1d417727ce3431de5804599aa48cd088f82dac81136ba3fc

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment linux · alpine · musl x64 cargo

Verification-run environments

Environment Contract Stages Run
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-17

Case

HOW
Goal
verify syn::ExprBinary in pkg:cargo/syn@3.0.3
Packages
Symbols
  • syn::ExprBinary
Created
2026-09-17T13:39:06Z

Contract

  1. syn::parse_str parses binary arithmetic expressions into ExprBinary with BinOp::Add and BinOp::Mul
  2. syn::parse_str parses binary comparison operations into ExprBinary with BinOp::Eq and BinOp::Lt
  3. syn::parse_str parses logical AND and OR operations into ExprBinary with BinOp::And and BinOp::Or
  4. ExprBinary preserves left and right operands as Box<Expr>
  5. syn::parse_str parses bitwise operations into ExprBinary with BinOp::BitXor and BinOp::BitAnd
  6. syn::parse_str parses nested binary expressions preserving left-associative tree structure

Files

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

Download the source artifact (tar.gz)

Source

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 = "quote"
version = "1.0.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
dependencies = [
 "proc-macro2",
]

[[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",
 "quote",
 "unicode-ident",
]

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

[dependencies]
syn = { version = "=3.0.3", features = ["full", "extra-traits"] }

[[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::ExprBinary 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::ExprBinary

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:873747af01458b8d77ebc8863bcdaef215f8b9b1286722f04d8a2072628697a5","contract":["syn::parse_str parses binary arithmetic expressions into ExprBinary with BinOp::Add and BinOp::Mul","syn::parse_str parses binary comparison operations into ExprBinary with BinOp::Eq and BinOp::Lt","syn::parse_str parses logical AND and OR operations into ExprBinary with BinOp::And and BinOp::Or","ExprBinary preserves left and right operands as Box\u003cExpr\u003e","syn::parse_str parses bitwise operations into ExprBinary with BinOp::BitXor and BinOp::BitAnd","syn::parse_str parses nested binary expressions preserving left-associative tree structure"],"goal":"verify syn::ExprBinary in pkg:cargo/syn@3.0.3","kind":"HOW","packages":["pkg:cargo/syn@3.0.3"],"schemaVersion":1,"symbols":["syn::ExprBinary"]},"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::ExprBinary"],"verifierAdapter":"cargo@1"}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify syn::ExprBinary in pkg:cargo/syn@3.0.3",
  "kind": "HOW",
  "packages": [
    "pkg:cargo/syn@3.0.3"
  ],
  "symbols": [
    "syn::ExprBinary"
  ]
}
src/lib.rs
//! Clean-room verification sample for syn::ExprBinary.

pub use syn::*;
test/contract.rs
use syn::{BinOp, Expr, ExprBinary};

fn main() {
    // 1. syn::parse_str parses binary arithmetic expressions into ExprBinary with BinOp::Add and BinOp::Mul
    let expr_add: Expr = syn::parse_str("x + y").expect("parse add");
    match expr_add {
        Expr::Binary(ExprBinary { op: BinOp::Add(_), left, right, .. }) => {
            assert!(matches!(*left, Expr::Path(_)));
            assert!(matches!(*right, Expr::Path(_)));
        }
        _ => panic!("expected ExprBinary with Add"),
    }
    let expr_mul: Expr = syn::parse_str("x * y").expect("parse mul");
    match expr_mul {
        Expr::Binary(ExprBinary { op: BinOp::Mul(_), .. }) => {}
        _ => panic!("expected ExprBinary with Mul"),
    }

    // 2. syn::parse_str parses binary comparison operations into ExprBinary with BinOp::Eq and BinOp::Lt
    let expr_eq: Expr = syn::parse_str("a == b").expect("parse eq");
    match expr_eq {
        Expr::Binary(ExprBinary { op: BinOp::Eq(_), .. }) => {}
        _ => panic!("expected ExprBinary with Eq"),
    }
    let expr_lt: Expr = syn::parse_str("a < b").expect("parse lt");
    match expr_lt {
        Expr::Binary(ExprBinary { op: BinOp::Lt(_), .. }) => {}
        _ => panic!("expected ExprBinary with Lt"),
    }

    // 3. syn::parse_str parses logical AND and OR operations into ExprBinary with BinOp::And and BinOp::Or
    let expr_and: Expr = syn::parse_str("cond1 && cond2").expect("parse and");
    match expr_and {
        Expr::Binary(ExprBinary { op: BinOp::And(_), .. }) => {}
        _ => panic!("expected ExprBinary with And"),
    }
    let expr_or: Expr = syn::parse_str("cond1 || cond2").expect("parse or");
    match expr_or {
        Expr::Binary(ExprBinary { op: BinOp::Or(_), .. }) => {}
        _ => panic!("expected ExprBinary with Or"),
    }

    // 4. ExprBinary preserves left and right operands as Box<Expr>
    let expr_lit: Expr = syn::parse_str("10 + 20").expect("parse int addition");
    if let Expr::Binary(ExprBinary { left, right, .. }) = expr_lit {
        match (*left, *right) {
            (Expr::Lit(l), Expr::Lit(r)) => {
                match (l.lit, r.lit) {
                    (syn::Lit::Int(li), syn::Lit::Int(ri)) => {
                        assert_eq!(li.base10_parse::<i32>().unwrap(), 10);
                        assert_eq!(ri.base10_parse::<i32>().unwrap(), 20);
                    }
                    _ => panic!("expected Lit::Int"),
                }
            }
            _ => panic!("expected Expr::Lit operands"),
        }
    } else {
        panic!("expected ExprBinary");
    }

    // 5. syn::parse_str parses bitwise operations into ExprBinary with BinOp::BitXor and BinOp::BitAnd
    let expr_xor: Expr = syn::parse_str("flags ^ mask").expect("parse xor");
    match expr_xor {
        Expr::Binary(ExprBinary { op: BinOp::BitXor(_), .. }) => {}
        _ => panic!("expected ExprBinary with BitXor"),
    }
    let expr_bitand: Expr = syn::parse_str("flags & mask").expect("parse bitand");
    match expr_bitand {
        Expr::Binary(ExprBinary { op: BinOp::BitAnd(_), .. }) => {}
        _ => panic!("expected ExprBinary with BitAnd"),
    }

    // 6. syn::parse_str parses nested binary expressions preserving left-associative tree structure
    let expr_nested: Expr = syn::parse_str("a + b + c").expect("parse chained addition");
    match expr_nested {
        Expr::Binary(ExprBinary { op: BinOp::Add(_), left, right, .. }) => {
            match *right {
                Expr::Path(p) => assert_eq!(p.path.segments[0].ident.to_string(), "c"),
                _ => panic!("expected right operand to be c"),
            }
            match *left {
                Expr::Binary(ExprBinary { op: BinOp::Add(_), left: inner_left, right: inner_right, .. }) => {
                    match (*inner_left, *inner_right) {
                        (Expr::Path(p1), Expr::Path(p2)) => {
                            assert_eq!(p1.path.segments[0].ident.to_string(), "a");
                            assert_eq!(p2.path.segments[0].ident.to_string(), "b");
                        }
                        _ => panic!("expected inner operands to be a and b"),
                    }
                }
                _ => panic!("expected left operand to be ExprBinary"),
            }
        }
        _ => panic!("expected ExprBinary"),
    }

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

Origin Seeder

anonymous