From c91596cdd2c7713a2e8b41dfa6880b104b278fc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20M=C3=BCller?= Date: Sat, 11 Jan 2025 22:07:35 -0800 Subject: [PATCH] Store default_log_filter as Cow In the future we anticipate adjusting the default filter to use, an effort that will in part piggy-back on the existing default_log_filter attribute. Swap its type to a Cow, so that if we use a statically defined default, we are not forced to allocate. --- macros/src/lib.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 985eb59..4697561 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -1,8 +1,10 @@ -// Copyright (C) 2019-2023 Daniel Mueller +// Copyright (C) 2019-2025 Daniel Mueller // SPDX-License-Identifier: (Apache-2.0 OR MIT) extern crate proc_macro; +use std::borrow::Cow; + use proc_macro::TokenStream; use proc_macro2::TokenStream as Tokens; @@ -93,7 +95,7 @@ fn try_test(attr: TokenStream, input: ItemFn) -> syn::Result { #[derive(Debug, Default)] struct AttributeArgs { - default_log_filter: Option, + default_log_filter: Option>, } impl AttributeArgs { @@ -132,7 +134,7 @@ impl AttributeArgs { if let Expr::Lit(lit) = &name_value.value { if let Lit::Str(lit_str) = &lit.lit { - *arg_ref = Some(lit_str.value()); + *arg_ref = Some(Cow::from(lit_str.value())); } }