CodeSampleX

サンプル

anyhow 1.0.104: Downcast concrete error types and custom context through anyhow::Error without losing concrete types across Box trait object boundaries or Deref std::error::Error coercions

検証済みサンプル — cargo anyhow 1.0.104: Downcast concrete error types and custom context through anyhow::Error without losing concrete types across Box trait object…

sha256:111c5fe00d1de4f527fc0ae3c444b12d048965ac957370eb4630a2a4a08b239f

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

実行証拠

宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。

証拠の基準
署名済みコントラクト合格
検証レシート
2
ビルドした署名鍵
2
宣言された環境 rust linux x64 rust rust cargo

検証実行環境

環境 コントラクト ステージ 実行日
rust 1 · linux alpine/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · cargo@1
2026-08-16
rust 1 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · cargo@1
2026-08-18

ケース

HOW
ゴール
Downcast concrete error types and custom context through anyhow::Error without losing concrete types across Box trait object boundaries or Deref std::error::Error coercions
パッケージ
シンボル
  • anyhow::Error::downcast_ref
  • anyhow::Error::downcast_mut
  • anyhow::Error::downcast
  • anyhow::Error::from_boxed
  • anyhow::Error::is
  • anyhow::Context::context
環境
rust
作成日
2026-08-16T07:54:47Z

コントラクト

  1. assert converting Box<dyn StdError> via from_boxed prevents recovering the concrete error with downcast_ref because TypeId tracks the boxed trait object
  2. assert converting a concrete StdError via From/into enables downcast_ref and is::<E>
  3. assert anyhow::Error::downcast_ref recursively searches through all attached context frames to find the root error
  4. assert std::error::Error::downcast_ref called via Deref on &dyn StdError fails on context-wrapped errors because std downcast does not traverse causes
  5. assert downcast_ref recovers custom context structs implementing Display and Debug even if they do not implement std::error::Error
  6. assert downcast_ref and downcast_mut on duplicate context types target the outermost most recently attached context frame
  7. assert downcast by value extracts the root error out of context layers, while mismatched downcast preserves the entire context chain intact
  8. assert context on Option None creates a root error with source None, whereas context on Result Err chains the previous error as source

ファイル

  • Cargo.lock
  • Cargo.toml
  • NOTES.md
  • csx.json
  • src/lib.rs

ソースアーティファクトをダウンロード (tar.gz)

オリジンシーダー

csx-seed