Macro freya::prelude::write_impls

macro_rules! write_impls {
    (
        $ty:ident
        // Accept generics
        < T $(, $gen:ident $(: $gen_bound:path)?)* $(,)?>
        // Accept extra bounds
        $(
            where
                $(
                    $extra_bound_ty:ident: $extra_bound:path
                ),+
        )?) => { ... };
}
Expand description

This macro is used to generate impl Add, impl AddAssign, impl Sub, impl SubAssign, impl Mul, impl MulAssign, impl Div, and impl DivAssign blocks for any Writable type that takes a generic T

§Example

use generational_box::*;
use dioxus::prelude::*;

struct MyCopyValue<T: 'static, S: Storage<T>> {
    value: CopyValue<T, S>,
}

impl<T: 'static, S: Storage<T>> Readable for MyCopyValue<T, S> {
    type Target = T;
    type Storage = S;

    fn try_read_unchecked(
        &self,
    ) -> Result<ReadableRef<'static, Self>, generational_box::BorrowError> {
        self.value.try_read_unchecked()
    }

    fn peek_unchecked(&self) -> ReadableRef<'static, Self> {
        self.value.read_unchecked()
    }
}

impl<T: 'static, S: Storage<T>> Writable for MyCopyValue<T, S> {
    fn try_write_unchecked(
        &self,
    ) -> Result<WritableRef<'static, Self>, generational_box::BorrowMutError> {
        self.value.try_write_unchecked()

     }

    //...
}

write_impls!(MyCopyValue<T, S: Storage<T>>);