commit | 70259aaf25cdfa3eb845d01e41589a22f4035eb9 | [log] [tgz] |
---|---|---|
author | James Farrell <[email protected]> | Tue May 21 15:04:10 2024 +0000 |
committer | Automerger Merge Worker <[email protected]> | Tue May 21 15:04:10 2024 +0000 |
tree | 2ed307f637804d94ea18b6a3a96038c19f43f839 | |
parent | e5ba7accff5147f85f948363081653d14d86974d [diff] | |
parent | ef75a6ca7b8778646f5d5e1563efe9a8c0dc357f [diff] |
Update Android.bp by running cargo_embargo am: 616aa4e37b am: ef75a6ca7b Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/downcast/+/3095558 Change-Id: I45a3689c7dc0ecd8c10d4fc352475fb223c3d465 Signed-off-by: Automerger Merge Worker <[email protected]>
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!