From 1c27b384610939e7a557de46541c0197a2451d47 Mon Sep 17 00:00:00 2001 From: Ted Driggs Date: Fri, 17 Nov 2023 05:48:47 -0800 Subject: [PATCH] impl FromMeta for PathBuf --- core/src/from_meta.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/core/src/from_meta.rs b/core/src/from_meta.rs index ff57ab0..ba2a3a2 100644 --- a/core/src/from_meta.rs +++ b/core/src/from_meta.rs @@ -203,6 +203,12 @@ impl FromMeta for String { } } +impl FromMeta for std::path::PathBuf { + fn from_string(s: &str) -> Result { + Ok(s.into()) + } +} + /// Generate an impl of `FromMeta` that will accept strings which parse to numbers or /// integer literals. macro_rules! from_meta_num { @@ -795,6 +801,14 @@ mod tests { assert_eq!(&fm::(quote!(ignore = r#"world"#)), "world"); } + #[test] + fn pathbuf_succeeds() { + assert_eq!( + fm::(quote!(ignore = r#"C:\"#)), + std::path::PathBuf::from(r#"C:\"#) + ); + } + #[test] #[allow(clippy::float_cmp)] // we want exact equality fn number_succeeds() {