Introduce Setting::some_or_not_set

This commit is contained in:
Louis Dureuil 2024-07-22 12:40:04 +02:00
parent 7a347966da
commit 553440632e
No known key found for this signature in database
2 changed files with 21 additions and 14 deletions

View file

@ -67,6 +67,13 @@ impl<T> Setting<T> {
}
}
pub fn some_or_not_set(option: Option<T>) -> Self {
match option {
Some(value) => Setting::Set(value),
None => Setting::NotSet,
}
}
pub const fn as_ref(&self) -> Setting<&T> {
match *self {
Self::Set(ref value) => Setting::Set(value),