macro_rules! declare_effect {
($name:ident -> $resume:ty) => { ... };
($name:ident($($field:tt)*) -> $resume:ty) => { ... };
($name:ident { $($field:tt)* } -> $resume:ty) => { ... };
($name:ident<$lt:lifetime>($($field:tt)*) -> $resume:ty) => { ... };
($name:ident<$lt:lifetime> { $($field:tt)* } -> $resume:ty) => { ... };
($name:ident<$T:ident : $bound:path>($($field:tt)*) -> $resume:ty) => { ... };
($name:ident<$T:ident : $bound:path> { $($field:tt)* } -> $resume:ty) => { ... };
}Expand description
Declare an effect type.
§Supported forms
No fields — creates a unit struct:
ⓘ
declare_effect!(MyEffect -> ());Tuple fields:
ⓘ
declare_effect!(MyEffect(pub String) -> bool);Named fields:
ⓘ
declare_effect!(MyEffect { path: String, recursive: bool } -> Vec<u8>);Lifetime parameter — the lifetime is added to the struct and impl:
ⓘ
declare_effect!(MyEffect<'a>(&'a str) -> bool);Generic type parameter — Sync + Send bounds are added automatically
on the impl:
ⓘ
declare_effect!(MyEffect<T: std::fmt::Debug>(T) -> T);The resume type may reference the GAT lifetime 'r to return borrowed data:
ⓘ
declare_effect!(MyEffect(i32) -> &'r str);