Skip to content

Commit

Permalink
Fix AsRefStr docs to specify lifetime constraints (#330)
Browse files Browse the repository at this point in the history
  • Loading branch information
DTrippe authored Feb 4, 2024
1 parent f746c36 commit 2056939
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion strum_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<str>` 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;
Expand Down

0 comments on commit 2056939

Please sign in to comment.