From 6ae6b0024e9f1e0cca78bde9c84513e6d08720d0 Mon Sep 17 00:00:00 2001 From: Hirrolot Date: Thu, 6 Oct 2022 17:54:31 +0600 Subject: [PATCH 1/2] Enhance an error message about a path --- src/fields_parse.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/fields_parse.rs b/src/fields_parse.rs index 1845812a..a94de2ae 100644 --- a/src/fields_parse.rs +++ b/src/fields_parse.rs @@ -12,15 +12,18 @@ pub(crate) enum ParserType { impl ParserType { pub fn parse(value: AttrValue) -> Result { - value.expect(r#""default", "split" or a path"#, |v| match v { - AttrValue::Path(p) => Ok(ParserType::Custom(p)), - AttrValue::Lit(syn::Lit::Str(ref l)) => match &*l.value() { - "default" => Ok(ParserType::Default), - "split" => Ok(ParserType::Split { separator: None }), + value.expect( + r#""default", "split", or a path for custom parsers"#, + |v| match v { + AttrValue::Path(p) => Ok(ParserType::Custom(p)), + AttrValue::Lit(syn::Lit::Str(ref l)) => match &*l.value() { + "default" => Ok(ParserType::Default), + "split" => Ok(ParserType::Split { separator: None }), + _ => Err(v), + }, _ => Err(v), }, - _ => Err(v), - }) + ) } } From ff2b479dc9f649cf7071f981ae28f7b6bc65a95f Mon Sep 17 00:00:00 2001 From: Hirrolot Date: Thu, 6 Oct 2022 18:02:28 +0600 Subject: [PATCH 2/2] Update the error message wording Co-authored-by: Waffle Maybe --- src/fields_parse.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fields_parse.rs b/src/fields_parse.rs index a94de2ae..599aa0c4 100644 --- a/src/fields_parse.rs +++ b/src/fields_parse.rs @@ -13,7 +13,7 @@ pub(crate) enum ParserType { impl ParserType { pub fn parse(value: AttrValue) -> Result { value.expect( - r#""default", "split", or a path for custom parsers"#, + r#""default", "split", or a path to a custom parser function"#, |v| match v { AttrValue::Path(p) => Ok(ParserType::Custom(p)), AttrValue::Lit(syn::Lit::Str(ref l)) => match &*l.value() {