bevy_pkv icon indicating copy to clipboard operation
bevy_pkv copied to clipboard

Missing `get_or_default` interfaces

Open davids91 opened this issue 6 months ago • 0 comments

Hey! Great library! I'm so glad this is available to use!

I think the following method would add to the usability of the library:

pub fn get_or<T: serde::de::DeserializeOwned>(
    pkv: &PkvStore,
    key: String,
    default_value: T,
) -> T {
    if let Ok(result) = pkv.get(key) {
        result
    } else {
        default_value
    }
}

davids91 avatar May 12 '25 12:05 davids91