CodeSampleX

サンプル

hashbrown 0.15.5: hashbrown::HashMap, hashbrown::HashSet, hashbrown::hash_map::Entry

検証済みサンプル — cargo hashbrown 0.15.5: hashbrown::HashMap, hashbrown::HashSet, hashbrown::hash_map::Entry. rust 1 · linux alpine/x64 · docker で contract…

sha256:e7f96af9e0542d58ed354ded178c93ef70f82bc6526558d507a65fd9ab2a44e8

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 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-03

ケース

HOW
ゴール
verify pkg:cargo/hashbrown@0.15.5
パッケージ
シンボル
  • hashbrown::HashMap
  • hashbrown::HashSet
  • hashbrown::hash_map::Entry
作成日
2026-11-03T23:50:22Z

コントラクト

  1. HashMap::new() inserts, overwrites, queries via get/get_key_value, and removes key-value pairs accurately
  2. HashMap::entry() supports Occupied/Vacant pattern matching and in-place mutation via and_modify().or_insert()
  3. HashMap::raw_entry_mut().from_key() mutates existing entries or lazily inserts new ones without cloning keys on lookup
  4. HashSet::from_iter() and intersection() compute set intersections accurately

ファイル

  • Cargo.lock
  • Cargo.toml
  • PROMPT.md
  • csx.json
  • spec.json
  • src/main.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 = "allocator-api2"
version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"

[[package]]
name = "equivalent"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826"

[[package]]
name = "foldhash"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"

[[package]]
name = "hashbrown"
version = "0.15.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
dependencies = [
 "allocator-api2",
 "equivalent",
 "foldhash",
]

[[package]]
name = "sample-hashbrown"
version = "0.1.0"
dependencies = [
 "hashbrown",
]
Cargo.toml
[package]
name = "sample-hashbrown"
version = "0.1.0"
edition = "2021"

[dependencies]
hashbrown = "=0.15.5"
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 pkg:cargo/hashbrown@0.15.5
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:cargo/hashbrown@0.15.5

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:99c8757b0af0426ce0118f1b19b626574f44ceb16ddf35b7a3371b44cc97eda2","contract":["HashMap::new() inserts, overwrites, queries via get/get_key_value, and removes key-value pairs accurately","HashMap::entry() supports Occupied/Vacant pattern matching and in-place mutation via and_modify().or_insert()","HashMap::raw_entry_mut().from_key() mutates existing entries or lazily inserts new ones without cloning keys on lookup","HashSet::from_iter() and intersection() compute set intersections accurately"],"goal":"verify pkg:cargo/hashbrown@0.15.5","kind":"HOW","packages":["pkg:cargo/hashbrown@0.15.5"],"schemaVersion":1,"symbols":["hashbrown::HashMap","hashbrown::HashSet","hashbrown::hash_map::Entry"]},"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/hashbrown@0.15.5"],"schemaVersion":1,"subject":"pkg:cargo/hashbrown@0.15.5","symbols":["hashbrown::HashMap","hashbrown::HashSet","hashbrown::hash_map::Entry"],"verifierAdapter":"cargo@1"}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:cargo/hashbrown@0.15.5",
  "kind": "HOW",
  "packages": [
    "pkg:cargo/hashbrown@0.15.5"
  ]
}
src/main.rs
use hashbrown::{HashMap, HashSet, hash_map::Entry};

fn main() {
    // 1. Basic HashMap creation, insertion, lookup, and removal
    let mut map: HashMap<String, i32> = HashMap::new();
    assert_eq!(map.insert("alpha".to_string(), 10), None);
    assert_eq!(map.insert("beta".to_string(), 20), None);
    assert_eq!(map.insert("alpha".to_string(), 15), Some(10));
    assert_eq!(map.get("alpha"), Some(&15));
    assert_eq!(map.get_key_value("beta"), Some((&"beta".to_string(), &20)));
    assert_eq!(map.len(), 2);

    // 2. Entry API (or_insert, and_modify, Occupied/Vacant)
    map.entry("beta".to_string()).and_modify(|v| *v += 5).or_insert(0);
    assert_eq!(map.get("beta"), Some(&25));
    match map.entry("gamma".to_string()) {
        Entry::Occupied(_) => panic!("expected vacant"),
        Entry::Vacant(v) => {
            v.insert(30);
        }
    }
    assert_eq!(map.remove("alpha"), Some(15));
    assert_eq!(map.len(), 2);

    // 3. Raw Entry API (unique to hashbrown: lookup/insert without cloning key)
    let mut raw_map: HashMap<String, usize> = HashMap::new();
    raw_map.insert("existing".to_string(), 1);
    raw_map
        .raw_entry_mut()
        .from_key("existing")
        .and_modify(|_k, v| *v += 10);
    assert_eq!(raw_map.get("existing"), Some(&11));

    raw_map
        .raw_entry_mut()
        .from_key("missing")
        .or_insert_with(|| ("missing".to_string(), 42));
    assert_eq!(raw_map.get("missing"), Some(&42));

    // 4. HashSet creation and set operations
    let a: HashSet<i32> = [1, 2, 3].into_iter().collect();
    let b: HashSet<i32> = [2, 3, 4].into_iter().collect();
    let intersection: HashSet<i32> = a.intersection(&b).copied().collect();
    assert_eq!(intersection.len(), 2);
    assert!(intersection.contains(&2) && intersection.contains(&3));

    println!("CONTRACT_OK");
}
test/contract.rs
// Contract verification runner for hashbrown@0.15.5 (invoked via cargo run --offline -> src/main.rs)

オリジンシーダー

匿名