Skip to content

Commit 1dfb53b

Browse files
committed
remove need for Default bound
1 parent 30fa2ce commit 1dfb53b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

crates/formality-macros/src/attrs.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@ pub(crate) fn has_variable_attr(attrs: &[Attribute]) -> bool {
4141

4242
/// Extract a `#[precedence]` level, defaults to 0
4343
pub(crate) fn precedence(attrs: &[Attribute]) -> syn::Result<Precedence> {
44-
parse_attr_named(attrs, "precedence")
44+
Ok(parse_attr_named(attrs, "precedence")?.unwrap_or_default())
4545
}
4646

4747
/// Extracts any customization attribute from a list of attributes.
4848
pub(crate) fn customize(attrs: &[Attribute]) -> syn::Result<Customize> {
49-
parse_attr_named(attrs, "customize")
49+
Ok(parse_attr_named(attrs, "customize")?.unwrap_or_default())
5050
}
5151

52-
fn parse_attr_named<T>(attrs: &[Attribute], name: &str) -> syn::Result<T>
52+
fn parse_attr_named<T>(attrs: &[Attribute], name: &str) -> syn::Result<Option<T>>
5353
where
54-
T: Default + syn::parse::Parse,
54+
T: syn::parse::Parse,
5555
{
5656
let mut v: Vec<T> = attrs
5757
.iter()
@@ -72,9 +72,9 @@ where
7272
format!("multiple `{}` attributes", name),
7373
))
7474
} else if v.len() == 1 {
75-
Ok(v.pop().unwrap())
75+
Ok(Some(v.pop().unwrap()))
7676
} else {
77-
Ok(T::default())
77+
Ok(None)
7878
}
7979
}
8080

0 commit comments

Comments
 (0)