euv-macros 0.18.21

Procedural macros for the euv UI framework, providing the macro and attribute for declarative UI composition.
Documentation
use super::*;

/// Helper body of the `my_component` free function.
#[component]
fn my_component() -> u32 {
    42
}

/// Helper body of the `pub_component` free function.
#[component]
pub fn pub_component() -> &'static str {
    "hello"
}

/// Helper body of the `generic_component` free function.
#[component]
fn generic_component<T: Default + Clone + 'static>() -> T {
    T::default()
}

#[test]
fn component_attribute_preserves_function_signature_no_args_returning_u32() {
    let result: u32 = my_component();
    assert_eq!(result, 42);
}

#[test]
fn component_attribute_preserves_pub_visibility() {
    let result: &'static str = pub_component();
    assert_eq!(result, "hello");
}

#[test]
fn component_attribute_preserves_generic_function() {
    let result: i32 = generic_component::<i32>();
    assert_eq!(result, 0);
}

#[test]
fn component_attribute_does_not_alter_function_name() {
    assert_eq!(my_component(), 42);
}