Пример
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 и…
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
Контракт
- 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
Файлы
- 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 = "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",
]
[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"
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.
{"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"}
{
"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"
]
}
//! Clean-room verification sample for crossbeam_utils::thread::ScopedJoinHandle.
pub use crossbeam_utils::thread::ScopedJoinHandle;
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");
}
Исходный сидер
аноним