feat!: no error without features
This commit is contained in:
-74
@@ -1,74 +0,0 @@
|
||||
/// Creates a [`HashMap`](bevy_utils::HashMap) from a list of key-value pairs.
|
||||
///
|
||||
/// Example:
|
||||
/// ```ignore
|
||||
/// let map = hashmap! {
|
||||
/// "key1" => "value1",
|
||||
/// "key2" => "value2"
|
||||
/// };
|
||||
#[macro_export]
|
||||
macro_rules! hashmap {
|
||||
($( $key: expr => $val: expr ),*) => {{
|
||||
let mut map = HashMap::new();
|
||||
$(
|
||||
map.insert($key, $val);
|
||||
)*
|
||||
map
|
||||
}};
|
||||
}
|
||||
|
||||
/// Applies common traits conditionally to items.
|
||||
///
|
||||
/// This macro is designed to reduce repetition and maintenance overhead by
|
||||
/// automatically deriving specified traits for each item passed to it based
|
||||
/// on the feature flags. It's intended for use with almost all types in this module.
|
||||
///
|
||||
/// # Features:
|
||||
/// - `serialize`: Derives `Serialize` and `Deserialize` traits and applies
|
||||
/// reflection for serialization if the `serialize` feature is enabled.
|
||||
/// - `reflect`: Derives the `Reflect` trait if the `reflect` feature is enabled.
|
||||
/// - `inspector-egui`: Derives `InspectorOptions` trait and applies reflection
|
||||
/// for the inspector if the `inspector-egui` feature is enabled.
|
||||
///
|
||||
/// # Usage
|
||||
/// To use this macro, wrap any item(s) you want to apply the common traits to.
|
||||
/// Each item can be a struct or enum that you want to derive traits for based
|
||||
/// on the feature flags.
|
||||
///
|
||||
/// # Example:
|
||||
/// ```ignore
|
||||
/// common_traits_conditions! {
|
||||
/// struct MyStruct {
|
||||
/// // fields
|
||||
/// }
|
||||
///
|
||||
/// enum MyEnum {
|
||||
/// // variants
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! common_traits_conditions {
|
||||
($($item:item)*) => {
|
||||
$(
|
||||
#[cfg_attr(
|
||||
feature = "serialize",
|
||||
derive(Serialize, Deserialize),
|
||||
)]
|
||||
#[cfg_attr(
|
||||
feature = "reflect",
|
||||
derive(Reflect),
|
||||
)]
|
||||
#[cfg_attr(
|
||||
all(feature = "reflect", feature = "serialize"),
|
||||
reflect(Serialize, Deserialize),
|
||||
)]
|
||||
#[cfg_attr(
|
||||
feature = "inspector-egui",
|
||||
derive(InspectorOptions),
|
||||
reflect(InspectorOptions),
|
||||
)]
|
||||
$item
|
||||
)*
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user