Skip to content

Commit 45323f7

Browse files
Peternator7Peter Glotfelty
and
Peter Glotfelty
authored
Use a "Path" instead of "String" for FromStr's error methods (#410)
Co-authored-by: Peter Glotfelty <peter@glotfelty.us>
1 parent b08ca81 commit 45323f7

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

strum_macros/src/helpers/metadata.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,12 @@ impl Parse for EnumMeta {
9595
} else if lookahead.peek(kw::parse_err_ty) {
9696
let kw = input.parse::<kw::parse_err_ty>()?;
9797
input.parse::<Token![=]>()?;
98-
let path_str: LitStr = input.parse()?;
99-
let path_tokens = parse_str(&path_str.value())?;
100-
let path = parse2(path_tokens)?;
98+
let path: Path = input.parse()?;
10199
Ok(EnumMeta::ParseErrTy { kw, path })
102100
} else if lookahead.peek(kw::parse_err_fn) {
103101
let kw = input.parse::<kw::parse_err_fn>()?;
104102
input.parse::<Token![=]>()?;
105-
let path_str: LitStr = input.parse()?;
106-
let path_tokens = parse_str(&path_str.value())?;
107-
let path = parse2(path_tokens)?;
103+
let path: Path = input.parse()?;
108104
Ok(EnumMeta::ParseErrFn { kw, path })
109105
} else if lookahead.peek(kw::const_into_str) {
110106
Ok(EnumMeta::ConstIntoStr(input.parse()?))

strum_tests/tests/from_str.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ fn color_default_with_white() {
232232

233233
#[derive(Debug, EnumString)]
234234
#[strum(
235-
parse_err_fn = "some_enum_not_found_err",
236-
parse_err_ty = "CaseCustomParseErrorNotFoundError"
235+
parse_err_fn = some_enum_not_found_err,
236+
parse_err_ty = CaseCustomParseErrorNotFoundError
237237
)]
238238
enum CaseCustomParseErrorEnum {
239239
#[strum(serialize = "red")]

0 commit comments

Comments
 (0)