Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new: Remove default_str and default_fn. #19

Merged
merged 3 commits into from May 22, 2023
Merged

new: Remove default_str and default_fn. #19

merged 3 commits into from May 22, 2023

Conversation

milesj
Copy link
Contributor

@milesj milesj commented May 22, 2023

Can now just use default.

TedDriggs/darling#229 (comment)

use syn::{Expr, ExprPath, Field, Type};
use syn::{Expr, ExprPath, Field, Meta, Type};

pub fn preserve_str_literal(meta: &Meta) -> darling::Result<Option<Expr>> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The plan is to make this function (without the Option in the return type) available as part of the darling crate; see TedDriggs/darling#235 for that.

You can achieve the desired result here by adding map = "Some" to the attribute that is consuming this function (see comment suggestion below)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks.


// #[setting()]
#[derive(FromAttributes, Default)]
#[darling(default, attributes(setting))]
pub struct SettingArgs {
#[darling(with = "preserve_str_literal")]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#[darling(with = "preserve_str_literal")]
#[darling(with = "preserve_str_literal", map = "Some")]

@milesj milesj merged commit 408d7ff into master May 22, 2023
5 of 6 checks passed
@milesj milesj deleted the default-str branch May 22, 2023 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants