mirror of
https://github.com/kristoferssolo/filecaster.git
synced 2025-10-21 19:00:34 +00:00
fix: error types
This commit is contained in:
parent
a8c5c84a5e
commit
b2cf463ff8
@ -38,7 +38,10 @@ pub fn impl_from_file(input: &DeriveInput) -> Result<TokenStream> {
|
|||||||
let mut default_bounds = Vec::new();
|
let mut default_bounds = Vec::new();
|
||||||
|
|
||||||
for field in fields {
|
for field in fields {
|
||||||
let ident = field.ident.as_ref().unwrap();
|
let ident = field
|
||||||
|
.ident
|
||||||
|
.as_ref()
|
||||||
|
.ok_or_else(|| Error::new_spanned(field, "Expected named fields"))?;
|
||||||
let ty = &field.ty;
|
let ty = &field.ty;
|
||||||
|
|
||||||
let mut default_expr = None;
|
let mut default_expr = None;
|
||||||
@ -78,11 +81,11 @@ pub fn impl_from_file(input: &DeriveInput) -> Result<TokenStream> {
|
|||||||
} else {
|
} else {
|
||||||
let mut where_clause = where_clause.cloned();
|
let mut where_clause = where_clause.cloned();
|
||||||
if let Some(wc) = &mut where_clause {
|
if let Some(wc) = &mut where_clause {
|
||||||
wc.predicates.extend(
|
for bound in default_bounds {
|
||||||
default_bounds
|
let predicate = parse2::<WherePredicate>(bound.clone())
|
||||||
.into_iter()
|
.map_err(|_| Error::new_spanned(&bound, "Failed to parse where predicate"))?;
|
||||||
.map(|bound| parse2::<WherePredicate>(bound).unwrap()),
|
wc.predicates.push(predicate);
|
||||||
);
|
}
|
||||||
} else {
|
} else {
|
||||||
where_clause = Some(parse_quote!(where #(#default_bounds),*));
|
where_clause = Some(parse_quote!(where #(#default_bounds),*));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user