CodeSampleX

샘플

crossbeam-utils 0.8.23: crossbeam_utils::thread::ScopedJoinHandle

검증된 샘플 — cargo crossbeam-utils 0.8.23: crossbeam_utils::thread::ScopedJoinHandle. rust 1 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다.

sha256:c2c881df15a172a7c29a6c187b3fa8e80ecdf2fe33d52c3fcd36b13bbefccc05

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. 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-11-06

케이스

HOW
목표
verify crossbeam_utils::thread::ScopedJoinHandle in pkg:cargo/crossbeam-utils@0.8.23
패키지
심벌
  • crossbeam_utils::thread::ScopedJoinHandle
생성일
2026-11-06T15:44:09Z

컨트랙트

  1. ScopedJoinHandle::join waits for a scoped thread borrowing stack data and returns Ok with its result
  2. ScopedJoinHandle::thread accesses the underlying ScopedThread metadata including thread name
  3. Multiple ScopedJoinHandle instances can concurrently mutate disjoint non-static stack slices and join cleanly
  4. ScopedJoinHandle::join catches a thread panic and returns Err without propagating the panic to the scope

파일

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

소스 아티팩트 내려받기 (tar.gz)

소스

Cargo.lock
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4

[[package]]
name = "crossbeam-utils"
version = "0.8.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6"

[[package]]
name = "sample-crossbeam-utils"
version = "1.0.0"
dependencies = [
 "crossbeam-utils",
]
Cargo.toml
[package]
name = "sample-crossbeam-utils"
version = "1.0.0"
edition = "2021"
publish = false

[dependencies]
crossbeam-utils = "=0.8.23"

[[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 crossbeam_utils::thread::ScopedJoinHandle in pkg:cargo/crossbeam-utils@0.8.23
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:cargo/crossbeam-utils@0.8.23
Demonstrate these symbols/APIs:
  - crossbeam_utils::thread::ScopedJoinHandle

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:b46baed6aacff50ac4e69925e267ba3e02b998e12e22c66b2902e267b2719fc8","contract":["ScopedJoinHandle::join waits for a scoped thread borrowing stack data and returns Ok with its result","ScopedJoinHandle::thread accesses the underlying ScopedThread metadata including thread name","Multiple ScopedJoinHandle instances can concurrently mutate disjoint non-static stack slices and join cleanly","ScopedJoinHandle::join catches a thread panic and returns Err without propagating the panic to the scope"],"goal":"verify crossbeam_utils::thread::ScopedJoinHandle in pkg:cargo/crossbeam-utils@0.8.23","kind":"HOW","packages":["pkg:cargo/crossbeam-utils@0.8.23"],"schemaVersion":1,"symbols":["crossbeam_utils::thread::ScopedJoinHandle"]},"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/crossbeam-utils@0.8.23"],"schemaVersion":1,"subject":"pkg:cargo/crossbeam-utils@0.8.23","symbols":["crossbeam_utils::thread::ScopedJoinHandle"],"verifierAdapter":"cargo@1"}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify crossbeam_utils::thread::ScopedJoinHandle in pkg:cargo/crossbeam-utils@0.8.23",
  "kind": "HOW",
  "packages": [
    "pkg:cargo/crossbeam-utils@0.8.23"
  ],
  "symbols": [
    "crossbeam_utils::thread::ScopedJoinHandle"
  ]
}
src/lib.rs
//! Clean-room verification sample for crossbeam_utils::thread::ScopedJoinHandle.

pub use crossbeam_utils::thread::ScopedJoinHandle;
test/contract.rs
use crossbeam_utils::thread::{scope, ScopedJoinHandle};

fn main() {
    // 1. Spawning a scoped thread returns ScopedJoinHandle which joins and returns the computed value
    let data = vec![10, 20, 30, 40];
    let sum = scope(|s| {
        let handle: ScopedJoinHandle<'_, i32> = s.spawn(|_| data.iter().sum());
        handle.join().expect("scoped thread should complete cleanly")
    })
    .expect("scope should succeed");
    assert_eq!(sum, 100);

    // 2. ScopedJoinHandle::thread exposes metadata such as the configured thread name
    scope(|s| {
        let handle: ScopedJoinHandle<'_, usize> = s
            .builder()
            .name("worker-alpha".to_string())
            .spawn(|_| 42)
            .expect("named thread spawn should succeed");

        assert_eq!(handle.thread().name(), Some("worker-alpha"));
        let debug_str = format!("{:?}", handle);
        assert!(debug_str.contains("ScopedJoinHandle"));

        let result = handle.join().expect("named thread should complete");
        assert_eq!(result, 42);
    })
    .expect("scope should succeed");

    // 3. Multiple ScopedJoinHandle instances can mutate disjoint stack slices concurrently
    let mut values = [1, 2, 3, 4];
    scope(|s| {
        let (left, right) = values.split_at_mut(2);
        let h1: ScopedJoinHandle<'_, ()> = s.spawn(move |_| {
            for v in left.iter_mut() {
                *v *= 10;
            }
        });
        let h2: ScopedJoinHandle<'_, ()> = s.spawn(move |_| {
            for v in right.iter_mut() {
                *v *= 100;
            }
        });
        h1.join().expect("left worker should join");
        h2.join().expect("right worker should join");
    })
    .expect("scope should succeed");
    assert_eq!(values, [10, 20, 300, 400]);

    // 4. ScopedJoinHandle::join captures a panic from the spawned thread as Err
    scope(|s| {
        let handle: ScopedJoinHandle<'_, ()> = s.spawn(|_| {
            panic!("expected thread failure");
        });
        let res = handle.join();
        assert!(res.is_err(), "joining a panicked thread must return Err");
    })
    .expect("scope should succeed when panic is handled via join");
}

오리진 시더

익명