Just wanted to report that the AsRefStr documentation is wrong. It claims it will create a static str reference, which doesn't seem to be true.
Converts enum variants to &'static str.
The lifetime of the reference is tied to the lifetime of the instance itself. E.,g
#[derive(strum::AsRefStr, strum::IntoStaticStr)]
enum MyVariant {
A
}
fn main() {
// Compiles fine
let variant_str: &'static str = {
let my_variant = MyVariant::A;
my_variant.into()
};
// Complains that my_variant is dropped while still borrowed
let variant_str: &'static str = {
let my_variant = MyVariant::A;
my_variant.as_ref()
};
}
Just feel the documentation could be more explicit, and direct people to IntoStaticStr
Just wanted to report that the AsRefStr documentation is wrong. It claims it will create a static str reference, which doesn't seem to be true.
The lifetime of the reference is tied to the lifetime of the instance itself. E.,g
Just feel the documentation could be more explicit, and direct people to IntoStaticStr