From 28f70467ca6d701701b3bcf8f9d3d819774776fa Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Thu, 4 Aug 2022 13:35:24 +0200 Subject: [PATCH] macros: Document event type aliases --- crates/ruma-macros/src/lib.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/ruma-macros/src/lib.rs b/crates/ruma-macros/src/lib.rs index f7f280e1..ea5aa2f7 100644 --- a/crates/ruma-macros/src/lib.rs +++ b/crates/ruma-macros/src/lib.rs @@ -98,6 +98,20 @@ pub fn event_enum(input: TokenStream) -> TokenStream { } /// Generates an implementation of `ruma_common::events::EventContent`. +/// +/// Also generates type aliases depending on the kind of event, with the final `Content` of the type +/// name removed and prefixed added. For instance, a message-like event content type +/// `FooEventContent` will have the following aliases generated: +/// +/// * `type FooEvent = MessageLikeEvent` +/// * `type SyncFooEvent = SyncMessageLikeEvent` +/// * `type OriginalFooEvent = OriginalMessageLikeEvent` +/// * `type OriginalSyncFooEvent = OriginalSyncMessageLikeEvent` +/// * `type RedactedFooEvent = RedactedMessageLikeEvent` +/// * `type RedactedSyncFooEvent = RedactedSyncMessageLikeEvent` +/// +/// You can use `cargo doc` to find out more details, its `--document-private-items` flag also lets +/// you generate documentation for binaries or private parts of a library. #[proc_macro_derive(EventContent, attributes(ruma_event))] pub fn derive_event_content(input: TokenStream) -> TokenStream { let ruma_common = import_ruma_common();