Registry / utility / downcast-rs

downcast-rs

JSON →
library2.0.2rscratesunverified

Provides safe trait object downcasting with support for type parameters, associated types, and type constraints.

# Cargo.toml [dependencies] downcast-rs = "2.0.2"
INSTALL
IMPORT
SIG · DOWNCAST-RS
D
downcast-rs
utilityrustv2.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Downcast
use downcast_rs::Downcast;

Downcasts a trait object to a concrete type.

use downcast_rs::Downcast; trait MyTrait: Downcast {} impl_downcast!(MyTrait); struct MyStruct; impl MyTrait for MyStruct {} fn main() { let obj: Box<dyn MyTrait> = Box::new(MyStruct); if let Some(concrete) = obj.downcast_ref::<MyStruct>() { println!("Downcast succeeded"); } }
Debug
Known issues

No known issues recorded.

Upgrade
Version history
2.0.2latest on crates.io
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources
downcast-rs — cargo add downcast-rs · libregistry