CodeSampleX

サンプル

anyhow 1.0.104: Convert anyhow::Error to Box<dyn StdError> via into_boxed_dyn_error vs reallocate_into_boxed_dyn_error_without_backtrace to retain downcastability, convert from boxed errors with Error::from_boxed, and mutate root errors through context layers via downcast_mut

検証済みサンプル — cargo anyhow 1.0.104: Convert anyhow::Error to Box<dyn StdError> via into_boxed_dyn_error vs reallocate_into_boxed_dyn_error_without_backtrace to…

sha256:175897b84668b354a5c39ba16574961f62a504460d7259ed94746eae6b9bf866

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。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
ゴール
Convert anyhow::Error to Box<dyn StdError> via into_boxed_dyn_error vs reallocate_into_boxed_dyn_error_without_backtrace to retain downcastability, convert from boxed errors with Error::from_boxed, and mutate root errors through context layers via downcast_mut
パッケージ
シンボル
  • anyhow::Error::into_boxed_dyn_error
  • anyhow::Error::reallocate_into_boxed_dyn_error_without_backtrace
  • anyhow::Error::from_boxed
  • anyhow::Error::downcast_mut
  • anyhow::Error::downcast_ref
環境
rust
作成日
2026-08-16T07:54:49Z

コントラクト

  1. assert into_boxed_dyn_error performs a zero-realloc pointer cast to Box<dyn StdError> whose Display matches but downcast_ref to the inner concrete type returns None
  2. assert reallocate_into_boxed_dyn_error_without_backtrace creates a new Box<dyn StdError> enabling downcast_ref and downcast to the concrete error type
  3. assert reallocate_into_boxed_dyn_error_without_backtrace on a context-wrapped error preserves the outermost Display and provides the full source chain
  4. assert Error::from_boxed converts a Box<dyn StdError> into anyhow::Error where direct downcast to the concrete type returns None but downcasting to Box<dyn StdError> recovers the boxed trait object
  5. assert downcast_mut traverses through multiple context layers allowing in-place mutation of the root error that persists across subsequent downcast_ref queries

ファイル

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

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

オリジンシーダー

csx-seed