Skip to content

Commit b5c142a

Browse files
committed
feat(derive) Remame #[memoryusage(ignore)] to #[loupe(skip)].
1 parent 2b7d1ad commit b5c142a

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

crates/loupe-derive/src/lib.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use syn::{
44
parse, Attribute, Data, DataEnum, DataStruct, DeriveInput, Fields, Generics, Ident, Index,
55
};
66

7-
#[proc_macro_derive(MemoryUsage, attributes(memoryusage))]
7+
#[proc_macro_derive(MemoryUsage, attributes(loupe))]
88
pub fn derive_memory_usage(input: TokenStream) -> TokenStream {
99
let derive_input: DeriveInput = parse(input).unwrap();
1010

@@ -61,7 +61,7 @@ fn derive_memory_usage_for_struct(
6161
.named
6262
.iter()
6363
.filter_map(|field| {
64-
if must_ignore(&field.attrs) {
64+
if must_skip(&field.attrs) {
6565
return None;
6666
}
6767

@@ -87,7 +87,7 @@ fn derive_memory_usage_for_struct(
8787
.iter()
8888
.enumerate()
8989
.filter_map(|(nth, field)| {
90-
if must_ignore(&field.attrs) {
90+
if must_skip(&field.attrs) {
9191
return None;
9292
}
9393

@@ -250,7 +250,7 @@ fn derive_memory_usage_for_enum(
250250
}
251251
};
252252

253-
if must_ignore(&variant.attrs) {
253+
if must_skip(&variant.attrs) {
254254
sum = quote! { 0 };
255255
}
256256

@@ -280,11 +280,11 @@ fn derive_memory_usage_for_enum(
280280
.into()
281281
}
282282

283-
fn must_ignore(attrs: &Vec<Attribute>) -> bool {
283+
fn must_skip(attrs: &Vec<Attribute>) -> bool {
284284
attrs.iter().any(|attr| {
285-
attr.path.is_ident("memoryusage")
285+
attr.path.is_ident("loupe")
286286
&& match attr.parse_args::<Ident>() {
287-
Ok(e) if e.to_string() == "ignore" => true,
287+
Ok(e) if e.to_string() == "skip" => true,
288288
_ => false,
289289
}
290290
})

crates/loupe-derive/tests/basic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fn test_struct_field_ignored() {
3535
#[allow(unused)]
3636
struct T {
3737
x: Vec<i32>,
38-
#[memoryusage(ignore)]
38+
#[loupe(skip)]
3939
y: Vec<i32>,
4040
}
4141

@@ -158,7 +158,7 @@ fn test_enum_variant_ignored() {
158158
#[allow(unused)]
159159
enum F {
160160
A,
161-
#[memoryusage(ignore)]
161+
#[loupe(skip)]
162162
Points(Vec<Point>),
163163
}
164164

0 commit comments

Comments
 (0)