From 2056939963527cc89f192239cb3c0262467ddb9d Mon Sep 17 00:00:00 2001 From: DTrippe <46032897+DTrippe@users.noreply.github.com> Date: Sun, 4 Feb 2024 08:31:39 -0700 Subject: [PATCH] Fix AsRefStr docs to specify lifetime constraints (#330) --- strum_macros/src/lib.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/strum_macros/src/lib.rs b/strum_macros/src/lib.rs index 72f8a37b..11a1cd7b 100644 --- a/strum_macros/src/lib.rs +++ b/strum_macros/src/lib.rs @@ -118,12 +118,15 @@ pub fn from_string(input: proc_macro::TokenStream) -> proc_macro::TokenStream { toks.into() } -/// Converts enum variants to `&'static str`. +/// Converts enum variants to `&'a str`, where `'a` is the lifetime of the input enum reference. /// /// Implements `AsRef` on your enum using the same rules as /// `Display` for determining what string is returned. The difference is that `as_ref()` returns /// a `&str` instead of a `String` so you don't allocate any additional memory with each call. /// +/// If you require a `&'static str`, you can use +/// [`strum::IntoStaticStr`](crate::IntoStaticStr) instead. +/// /// ``` /// // You need to bring the AsRef trait into scope to use it /// use std::convert::AsRef;