| 1 | // SPDX-License-Identifier: Apache-2.0 OR MIT |
| 2 | |
| 3 | //! Rust standard library vendored code. |
| 4 | //! |
| 5 | //! The contents of this file come from the Rust standard library, hosted in |
| 6 | //! the <https://github.com/rust-lang/rust> repository, licensed under |
| 7 | //! "Apache-2.0 OR MIT" and adapted for kernel use. For copyright details, |
| 8 | //! see <https://github.com/rust-lang/rust/blob/master/COPYRIGHT>. |
| 9 | |
| 10 | use crate; |
| 11 | use Any; |
| 12 | |
| 13 | |
| 14 | /// Attempt to downcast the `Arc<dyn Any + Send + Sync>` to a concrete type. |
| 15 | |
| 16 | |
| 17 | T: Any + Send + Sync, |
| 18 | |
| 19 | if . |
| 20 | // SAFETY: We have just checked that the type is correct, so we can cast the pointer. |
| 21 | unsafe |
| 22 | let ptr = self.ptr.; |
| 23 | forget; |
| 24 | Ok |
| 25 | |
| 26 | else |
| 27 | Err |
| 28 | |
| 29 | |
| 30 |