commit | 616aa4e37bfc195d91c608f1f9b697b3ae2ad744 | [log] [tgz] |
---|---|---|
author | James Farrell <jamesfarrell@google.com> | Mon May 20 17:06:20 2024 +0000 |
committer | James Farrell <jamesfarrell@google.com> | Mon May 20 17:06:20 2024 +0000 |
tree | 7dc4f45a506b98adaf2b3ddb3d89de6d8d572599 | |
parent | 79e13f886c6695768c6a4aedd9386738371195bc [diff] |
Update Android.bp by running cargo_embargo Test: ran cargo_embargo Change-Id: I53b5f51659d177ef0eaae71647be4fe47cfc0c03
A trait (& utilities) for downcasting trait objects back to their original types.
Add to your Cargo.toml:
[dependencies] downcast = "0.12"
Add to your crate root:
#[macro_use] extern crate downcast;
Arc
-pointers.Downcast::downcast()
).Any::type_name()
).Q: I'm getting the size for values of type XXX cannot be known at compile time
errors, what am i doing wrong?
A: Make sure you use the corresponding Any
bound along with the Downcast
traits. So, Any
for Downcast
and AnySync
for DowncastSync
.
Q: Can i cast trait objects to trait objects?
A: No, that is currently no possible in safe rust - and unsafe solutions are very tricky, as well. If you found a solution, feel free to share it!
Q: What is the difference between this and the downcast-rs
crate on crates.io?
A: At the moment, there isn't one, really. There was an unfortunate naming clash. You may consider using the other crate, as it is more actively maintained. This one is considered feature-complete and frozen in functionality. Hopefully, one day, the Rust language will make downcasting easier and we will need neither of these crates anymore!