all: split reusable components into workspace crates
This commit is contained in:
parent
2a079ed800
commit
657e7ce2f7
225 changed files with 7422 additions and 17602 deletions
9
utils/src/option_ext.rs
Normal file
9
utils/src/option_ext.rs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
pub trait OptionExt<T> {
|
||||
fn get_or_insert_default_ext(&mut self) -> &mut T;
|
||||
}
|
||||
|
||||
impl<T: Default> OptionExt<T> for Option<T> {
|
||||
fn get_or_insert_default_ext(&mut self) -> &mut T {
|
||||
self.get_or_insert_with(|| Default::default())
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue