Repository: TedDriggs/darling (rust)

Issue:
Field-level default should take path without quotation marks
The [`DefaultExpression`](https://github.com/TedDriggs/darling/blob/master/core/src/options/mod.rs#L35) type was never updated to accept a path in the right-hand side. This means that `#[darling(default = path_to_fn)]` doesn't work, while `#[darling(default = "path_to_fn")]` does. We should allow the quotation-free form.

Pull request description:
Accept bare paths in #[darling(default = ...)]
Fixes #257

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 359f98b..27b36f7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # Changelog
 
+## Unreleased
+
+- Accept bare paths in `#[darling(default = ...)]` [#258](https://github.com/TedDriggs/darling/pull/258)
+
 ## v0.20.3 (July 12, 2023)
 
 - Add `FromMeta` impl for `u128` and `i128` [#243](https://github.com/TedDriggs/darling/pull/243)
diff --git a/core/src/options/mod.rs b/core/src/options/mod.rs
index 066aa1c..164d21f 100644
--- a/core/src/options/mod.rs
+++ b/core/src/options/mod.rs
@@ -55,6 +55,10 @@ impl FromMeta for DefaultExpression {
         }
     }
 
+    fn from_expr(expr: &syn::Expr) -> Result<Self> {
+        syn::Path::from_expr(expr).map(DefaultExpression::Explicit)
+    }
+
     fn from_value(value: &syn::Lit) -> Result<Self> {
         syn::Path::from_value(value).map(DefaultExpression::Explicit)
     }


Test patch:
diff --git a/tests/defaults.rs b/tests/defaults.rs
index 05ab1ed..b74c745 100644
--- a/tests/defaults.rs
+++ b/tests/defaults.rs
@@ -12,7 +12,7 @@ mod foo {
 #[derive(FromDeriveInput)]
 #[darling(attributes(speak))]
 pub struct SpeakerOpts {
-    #[darling(default = "foo::bar::init")]
+    #[darling(default = foo::bar::init)]
     first_word: String,
 }