Skip to content

default filter that filters Option::None #393

Answered by g4borg
g4borg asked this question in Q&A
Discussion options

You must be logged in to vote

Just found .is_none() on value 😆

so a copy of default() and expanding it like this

pub fn none(value: Value, other: Option<Value>) -> Value {
    if value.is_undefined() || value.is_none() {
        other.unwrap_or_else(|| Value::from(""))
    } else {
        value
    }
}

did it.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by g4borg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant