From 804a94176237ac3a9f3e171fa06c1a2c8db4864e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Thu, 9 Sep 2021 20:29:04 +0200 Subject: [PATCH] docs(rust): Run the register event handler doc example --- matrix_sdk/src/client.rs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/matrix_sdk/src/client.rs b/matrix_sdk/src/client.rs index 272c49e3..e1634dda 100644 --- a/matrix_sdk/src/client.rs +++ b/matrix_sdk/src/client.rs @@ -920,8 +920,10 @@ impl Client { /// /// # Examples /// - /// ```no_run - /// # let client: matrix_sdk::Client = unimplemented!(); + /// ``` + /// # use url::Url; + /// # let homeserver = Url::parse("http://localhost:8080").unwrap(); + /// # let client = Client::new(homeserver).unwrap(); /// use matrix_sdk::{ /// room::Room, /// ruma::{ @@ -940,18 +942,21 @@ impl Client { /// # let _ = async { /// client /// .register_event_handler( - /// |ev: SyncMessageEvent, room: Room, client: Client| async move { + /// |ev: SyncMessageEvent, + /// room: Room, + /// client: Client| async move { /// // Common usage: Room event plus room and client. /// }, /// ) /// .await - /// .register_event_handler(|ev: SyncStateEvent| async move { - /// // Also possible: Omit any or all arguments after the first. - /// }) - /// .await; + /// .register_event_handler( + /// |ev: SyncStateEvent| async move { + /// // Also possible: Omit any or all arguments after the first. + /// } + /// ).await; /// - /// // Custom events work exactly the same way, you just need to declare the content struct and - /// // use the EventContent derive macro on it. + /// // Custom events work exactly the same way, you just need to declare + /// // the content struct and use the EventContent derive macro on it. /// #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] /// #[ruma_event(type = "org.shiny_new_2fa.token", kind = Message)] /// struct TokenEventContent {