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

Add convenience method to MaybeUndefined #881

Closed
djc opened this issue Mar 30, 2022 · 1 comment
Closed

Add convenience method to MaybeUndefined #881

djc opened this issue Mar 30, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@djc
Copy link
Contributor

djc commented Mar 30, 2022

Description of the feature

It might be nice if MaybeUndefined knew how to update an Option<T> in place. Something like this:

fn update_if_defined(self, current: &mut Option<T>) {
    match self {
        MaybeUndefined::Value(new) => *current = Some(new),
        MaybeUndefined::Null => *current = None,
        MaybeUndefined::Undefined => {},
    };
}

What do you think? Worth thinking about whether this is a good name, too.

@djc djc added the enhancement New feature or request label Mar 30, 2022
@sunli829
Copy link
Collaborator

This method is very useful. 🙂

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

No branches or pull requests

2 participants