Skip to content

Commit 32df986

Browse files
authored
Merge branch 'sigp:main' into enum-variant-attributes
2 parents 2ad6eb1 + 142de7f commit 32df986

12 files changed

+22
-6
lines changed

.github/workflows/gh-pages.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
jobs:
1010
deploy:
11-
runs-on: ubuntu-20.04
11+
runs-on: ubuntu-latest
1212
concurrency:
1313
group: ${{ github.workflow }}-${{ github.ref }}
1414
steps:

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "superstruct"
3-
version = "0.8.0"
3+
version = "0.9.0"
44
edition = "2021"
55
description = "Versioned data types with minimal boilerplate"
66
license = "Apache-2.0"

src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ pub fn superstruct(args: TokenStream, input: TokenStream) -> TokenStream {
271271
let is_common_meta = opts
272272
.meta_variants
273273
.as_ref()
274-
.map_or(true, |struct_meta_variants| {
274+
.is_none_or(|struct_meta_variants| {
275275
struct_meta_variants.idents.len() == field_meta_variants.len()
276276
});
277277
let is_common = field_variants.len() == variant_names.len() && is_common_meta;
@@ -1178,7 +1178,7 @@ fn is_superstruct_attr(attr: &Attribute) -> bool {
11781178
fn is_attr_with_ident(attr: &Attribute, ident: &str) -> bool {
11791179
attr.path()
11801180
.get_ident()
1181-
.map_or(false, |attr_ident| *attr_ident == ident)
1181+
.is_some_and(|attr_ident| *attr_ident == ident)
11821182
}
11831183

11841184
/// Predicate for determining whether a field should be excluded from a flattened
@@ -1195,7 +1195,7 @@ fn should_skip(
11951195
Override::Inherit => false,
11961196
Override::Explicit(map) => {
11971197
let contains_variant = map.contains_key(variant);
1198-
let contains_meta_variant = meta_variant.map_or(true, |mv| map.contains_key(mv));
1198+
let contains_meta_variant = meta_variant.is_none_or(|mv| map.contains_key(mv));
11991199

12001200
let variants_exist = variant_names.iter().any(|v| map.contains_key(v));
12011201
let meta_variants_exist = meta_variant_names

src/utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub fn snake_case(ident: &str) -> String {
2626
/// Create a generics block like `<_, _, _>` with `num_generics` underscores.
2727
pub fn underscore_generics(num_generics: usize) -> proc_macro2::TokenStream {
2828
let underscore = Token![_](Span::call_site());
29-
let underscores = std::iter::repeat(quote! { #underscore }).take(num_generics);
29+
let underscores = std::iter::repeat_n(quote! { #underscore }, num_generics);
3030
quote! { <#(#underscores),*> }
3131
}
3232

tests/basic.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(non_local_definitions)] // for macros on structs within test functions
2+
13
use serde::Deserialize;
24
use superstruct::superstruct;
35

tests/flatten.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(non_local_definitions)] // for macros on structs within test functions
2+
13
use superstruct::superstruct;
24

35
#[test]

tests/from.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(non_local_definitions)] // for macros on structs within test functions
2+
13
use std::fmt::Display;
24
use superstruct::superstruct;
35

tests/map_macro.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(non_local_definitions)] // for macros on structs within test functions
2+
13
use superstruct::superstruct;
24

35
#[test]

tests/meta_variant.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(non_local_definitions)] // for macros on structs within test functions
2+
13
use superstruct::superstruct;
24

35
#[superstruct(

tests/ref.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(non_local_definitions)] // for macros on structs within test functions
2+
13
use superstruct::superstruct;
24

35
// Check that we can convert a Ref to an inner reference with the same lifetime as `message`.

tests/ref_mut.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(non_local_definitions)] // for macros on structs within test functions
2+
13
use superstruct::superstruct;
24

35
#[test]

tests/specific_variant_attributes.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(non_local_definitions)] // for macros on structs within test functions
2+
13
use superstruct::superstruct;
24

35
#[superstruct(

0 commit comments

Comments
 (0)