샘플
once_cell_polyfill 1.70.2
검증된 샘플 — cargo once_cell_polyfill 1.70.2. rust 1 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: OnceLock::new creates an empty uninitialized cell and…
sha256:bc79d8900cdf2e7f659e122f39640c35a168a5e9d4c09883f0a953aeb228a7bf
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 2
- 빌드한 서명 키
- 1
선언된 환경
linux · alpine · musl x64 cargo
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| rust 1 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | SKIPPED | compile:SKIPPED · contract:SKIPPED · load:SKIPPED · resolve:FAIL CONTAINER_RUN · cargo@1rust:1-alpine@sha256:a10e64dd139b… |
2026-10-11 |
| 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-11 |
케이스
HOW- 목표
- verify pkg:cargo/once_cell_polyfill@1.70.2
- 생성일
- 2026-10-11T15:40:00Z
컨트랙트
- OnceLock::new creates an empty uninitialized cell and get returns None
- OnceLock::set sets the value and returns Ok, but returns Err on subsequent sets
- OnceLock::get_or_init computes and caches the value on first call
- OnceLock::get_mut and take allow mutating or extracting the value from an unshared cell
- OnceLock::into_inner consumes the cell and returns the contained value
- OnceLock implements From, Default, Clone, and PartialEq
- OnceLock safely coordinates concurrent initialization across threads
파일
- 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 = "once_cell_polyfill"
version = "1.70.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
[[package]]
name = "sample-once-cell-polyfill"
version = "1.0.0"
dependencies = [
"once_cell_polyfill",
]
[package]
name = "sample-once-cell-polyfill"
version = "1.0.0"
edition = "2021"
publish = false
[dependencies]
once_cell_polyfill = "=1.70.2"
[[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 pkg:cargo/once_cell_polyfill@1.70.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/once_cell_polyfill@1.70.2
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:cfd7d6f03993bbc7b7c8f737fec03dde014089015ba9aad4db0f3629c4852f5f","contract":["OnceLock::new creates an empty uninitialized cell and get returns None","OnceLock::set sets the value and returns Ok, but returns Err on subsequent sets","OnceLock::get_or_init computes and caches the value on first call","OnceLock::get_mut and take allow mutating or extracting the value from an unshared cell","OnceLock::into_inner consumes the cell and returns the contained value","OnceLock implements From, Default, Clone, and PartialEq","OnceLock safely coordinates concurrent initialization across threads"],"goal":"verify pkg:cargo/once_cell_polyfill@1.70.2","kind":"HOW","packages":["pkg:cargo/once_cell_polyfill@1.70.2"],"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/once_cell_polyfill@1.70.2"],"schemaVersion":1,"subject":"pkg:cargo/once_cell_polyfill@1.70.2","verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify pkg:cargo/once_cell_polyfill@1.70.2",
"kind": "HOW",
"packages": [
"pkg:cargo/once_cell_polyfill@1.70.2"
]
}
//! Clean-room verification sample for once_cell_polyfill.
pub use once_cell_polyfill::*;
use once_cell_polyfill::sync::OnceLock;
use std::sync::Arc;
use std::thread;
fn main() {
// 1. OnceLock::new creates an empty uninitialized cell and get returns None
let cell: OnceLock<u32> = OnceLock::new();
assert!(cell.get().is_none());
// 2. OnceLock::set sets the value and returns Ok, but returns Err on subsequent sets
let cell: OnceLock<u32> = OnceLock::new();
assert_eq!(cell.set(42), Ok(()));
assert_eq!(cell.get(), Some(&42));
assert_eq!(cell.set(99), Err(99));
assert_eq!(cell.get(), Some(&42));
// 3. OnceLock::get_or_init computes and caches the value on first call
let cell: OnceLock<String> = OnceLock::new();
let mut init_count = 0;
let val1 = cell.get_or_init(|| {
init_count += 1;
"computed".to_string()
});
assert_eq!(val1, "computed");
assert_eq!(init_count, 1);
let val2 = cell.get_or_init(|| {
init_count += 1;
"other".to_string()
});
assert_eq!(val2, "computed");
assert_eq!(init_count, 1);
// 4. OnceLock::get_mut and take allow mutating or extracting the value from an unshared cell
let mut cell: OnceLock<i32> = OnceLock::new();
cell.set(10).unwrap();
if let Some(val) = cell.get_mut() {
*val += 5;
}
assert_eq!(cell.get(), Some(&15));
let taken = cell.take();
assert_eq!(taken, Some(15));
assert!(cell.get().is_none());
// 5. OnceLock::into_inner consumes the cell and returns the contained value
let cell: OnceLock<String> = OnceLock::new();
cell.set("hello".to_string()).unwrap();
assert_eq!(cell.into_inner(), Some("hello".to_string()));
let empty: OnceLock<i32> = OnceLock::new();
assert_eq!(empty.into_inner(), None);
// 6. OnceLock implements From, Default, Clone, and PartialEq
let from_cell: OnceLock<i32> = OnceLock::from(100);
assert_eq!(from_cell.get(), Some(&100));
let default_cell: OnceLock<i32> = OnceLock::default();
assert!(default_cell.get().is_none());
let cloned = from_cell.clone();
assert_eq!(cloned.get(), Some(&100));
assert_eq!(from_cell, cloned);
// 7. OnceLock safely coordinates concurrent initialization across threads
let thread_cell = Arc::new(OnceLock::new());
let mut handles = Vec::new();
for _ in 0..10 {
let cell_clone = Arc::clone(&thread_cell);
handles.push(thread::spawn(move || {
*cell_clone.get_or_init(|| 42)
}));
}
for h in handles {
let res = h.join().unwrap();
assert_eq!(res, 42);
}
assert_eq!(thread_cell.get(), Some(&42));
println!("All once_cell_polyfill contract assertions passed successfully.");
}
오리진 시더
익명