1
0
Fork 0
forked from wry/wry

text: render text asynchronously

This commit is contained in:
Julian Orth 2024-09-28 18:03:23 +02:00
parent d9eb14e2bc
commit 12f358c0d9
12 changed files with 893 additions and 421 deletions

View file

@ -201,13 +201,20 @@ impl<K: Eq, V, const N: usize> SmallMapMut<K, V, N> {
pub fn get_or_default_mut(&mut self, k: K) -> &mut V
where
V: Default,
{
self.get_or_insert_with(k, || V::default())
}
pub fn get_or_insert_with<F>(&mut self, k: K, f: F) -> &mut V
where
F: FnOnce() -> V,
{
for (ek, ev) in &mut self.m {
if ek == &k {
return unsafe { (ev as *mut V).deref_mut() };
}
}
self.m.push((k, V::default()));
self.m.push((k, f()));
&mut self.m.last_mut().unwrap().1
}