File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed
crates/formality-macros/src Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -41,17 +41,17 @@ pub(crate) fn has_variable_attr(attrs: &[Attribute]) -> bool {
41
41
42
42
/// Extract a `#[precedence]` level, defaults to 0
43
43
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 ( ) )
45
45
}
46
46
47
47
/// Extracts any customization attribute from a list of attributes.
48
48
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 ( ) )
50
50
}
51
51
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 > >
53
53
where
54
- T : Default + syn:: parse:: Parse ,
54
+ T : syn:: parse:: Parse ,
55
55
{
56
56
let mut v: Vec < T > = attrs
57
57
. iter ( )
72
72
format ! ( "multiple `{}` attributes" , name) ,
73
73
) )
74
74
} else if v. len ( ) == 1 {
75
- Ok ( v. pop ( ) . unwrap ( ) )
75
+ Ok ( Some ( v. pop ( ) . unwrap ( ) ) )
76
76
} else {
77
- Ok ( T :: default ( ) )
77
+ Ok ( None )
78
78
}
79
79
}
80
80
You can’t perform that action at this time.
0 commit comments