-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Turn crate into no_std using core + alloc
Extensions are also made an optional feature to not require depending on HashMap
- Loading branch information
Showing
21 changed files
with
338 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
macro_rules! if_downcast_into { | ||
($in_ty:ty, $out_ty:ty, $val:ident, $body:expr) => ({ | ||
if std::any::TypeId::of::<$in_ty>() == std::any::TypeId::of::<$out_ty>() { | ||
($in_ty:ty, $out_ty:ty, $val:ident, $body:expr) => {{ | ||
if core::any::TypeId::of::<$in_ty>() == core::any::TypeId::of::<$out_ty>() { | ||
// Store the value in an `Option` so we can `take` | ||
// it after casting to `&mut dyn Any`. | ||
let mut slot = Some($val); | ||
// Re-write the `$val` ident with the downcasted value. | ||
let $val = (&mut slot as &mut dyn std::any::Any) | ||
let $val = (&mut slot as &mut dyn core::any::Any) | ||
.downcast_mut::<Option<$out_ty>>() | ||
.unwrap() | ||
.take() | ||
.unwrap(); | ||
// Run the $body in scope of the replaced val. | ||
$body | ||
} | ||
}) | ||
}}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.