Clean up checking code a bit

This commit is contained in:
Richard Dodd
2018-08-21 13:11:53 +01:00
parent 385e805509
commit 5342a26fd0

View File

@ -1115,18 +1115,14 @@ fn assert_last_param_is_slice(decl: &syn::FnDecl) -> Result<(), Diagnostic> {
}
let arg = decl.inputs.last().ok_or_else(|| not_slice_error(&decl.inputs))?;
let ty = match arg.value() {
syn::FnArg::Captured(ref arg_cap) => &arg_cap.ty,
_ => return Err(not_slice_error(&arg))
};
match ty {
syn::Type::Reference(ref ref_ty) => match &*ref_ty.elem {
syn::Type::Slice(_) => Ok(()),
_ => Err(not_slice_error(ty))
},
_ => Err(not_slice_error(ty))
if let syn::FnArg::Captured(ref arg_cap) = arg.value() {
if let syn::Type::Reference(ref ref_ty) = arg_cap.ty {
if let syn::Type::Slice(_) = *ref_ty.elem {
return Ok(())
}
}
}
Err(not_slice_error(&arg))
}
/// If the path is a single ident, return it.