it: test window gains kb focus when mapped
This commit is contained in:
parent
cbf539cbcc
commit
c827a93dbb
19 changed files with 672 additions and 39 deletions
26
src/utils/once.rs
Normal file
26
src/utils/once.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#![allow(dead_code)]
|
||||
|
||||
use std::{cell::Cell, future::Future};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Once {
|
||||
done: Cell<bool>,
|
||||
}
|
||||
|
||||
impl Once {
|
||||
pub fn set(&self) -> bool {
|
||||
!self.done.replace(true)
|
||||
}
|
||||
|
||||
pub fn exec<F: FnOnce()>(&self, f: F) {
|
||||
if !self.done.replace(true) {
|
||||
f();
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn exec_async<G: Future<Output = ()>, F: FnOnce() -> G>(&self, f: F) {
|
||||
if !self.done.replace(true) {
|
||||
f().await;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue