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

Allow both Option=! and Option=WrappedType for optional fields #34

Closed
RustyNova016 opened this issue Oct 30, 2024 · 3 comments · Fixed by #35
Closed

Allow both Option=! and Option=WrappedType for optional fields #34

RustyNova016 opened this issue Oct 30, 2024 · 3 comments · Fixed by #35
Assignees
Labels
enhancement New feature or request

Comments

@RustyNova016
Copy link

Currently, you need to choose between whether giving an Option or a value for optional fields. But sometimes, it's easier to give an option to a builder, and others a value.

It would be great to have a Builder::field_optional() function when using Option=WrappedType that takes in a Option, allowing for both styles depending on the use of the builder

@loganmzz loganmzz self-assigned this Oct 31, 2024
@loganmzz
Copy link
Owner

Sounds good.

I may also add a setting (to be defined) when set makes available following functions:

// Named
fn field<T: Into<X>>(value: Option<T>) {}
fn field_some<T: Into<X>>(value: T) {}
fn field_none() {}

// Tuple - Unordered
fn set0<T: Into<X>>(value: Option<T>) {}
fn set0_some<T: Into<X>>(value: T) {}
fn set0_none() {}

// Tuple - Ordered
fn set<T: Into<X>>(value: Option<T>) {}
fn some<T: Into<X>>(value: T) {}
fn none() {}

As I'm giving a talk (about Rust btw :) ) next week, I won't have time to take a look until next week-end.

@loganmzz
Copy link
Owner

loganmzz commented Dec 17, 2024

@RustyNova016 Sorry for the delay, I have released 1.3.0, but without setting to reverse optional setters (Option by default and field_some() for wrapped type)

@RustyNova016
Copy link
Author

Neat! Thanks.

@loganmzz loganmzz added the enhancement New feature or request label Feb 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants