From 2832dff7f1b18fd33d171d8a678918650a3eca2d Mon Sep 17 00:00:00 2001 From: szymon Date: Sun, 4 Oct 2026 14:17:10 +0200 Subject: [PATCH] docs: add example to init --- src/api/functions.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/api/functions.rs b/src/api/functions.rs index 3b73133..face787 100644 --- a/src/api/functions.rs +++ b/src/api/functions.rs @@ -9,10 +9,26 @@ use super::libnotify::*; *(what a cool section comment) */ -/// Initialized libnotify. This must be called before any other functions. +/// Initializes libnotify. This must be called before any other functions. /// /// Starting from 0.8, if the provided app_name is NULL, libnotify will try to figure it out from the running application. Before it was not allowed, and was causing libnotify not to be initialized. /// +/// # Example +/// +/// ``` +/// use libnotify_rs::api::{ +/// functions::init, +/// notification:: Notification, +/// }; +/// +/// fn main() -> Result<(), Box> { +/// init("Test app")?; // we need to init libnotify __before__ any other libnotify code +/// let notification = Notification::new("Test", None, None)?; // Some libnotify call +/// Ok(()) +/// } +/// +/// ``` +/// /// # Errors /// This function can return LibnotifyError::{InitError, NulError} pub fn init<'a, T>(app_name: T) -> Result<(), LibnotifyError>