diff options
Diffstat (limited to '')
-rw-r--r-- | native/src/clipboard.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/native/src/clipboard.rs b/native/src/clipboard.rs index 081b4004..62dfc130 100644 --- a/native/src/clipboard.rs +++ b/native/src/clipboard.rs @@ -21,3 +21,20 @@ impl Clipboard for Null { fn write(&mut self, _contents: String) {} } + +pub enum Action<T> { + Read(Box<dyn Fn(Option<String>) -> T>), + Write(Box<dyn Fn(String) -> T>), +} + +impl<T> Action<T> { + pub fn map<A>(self, f: impl Fn(T) -> A + 'static + Send + Sync) -> Action<A> + where + T: 'static, + { + match self { + Self::Read(o) => Action::Read(Box::new(move |s| f(o(s)))), + Self::Write(o) => Action::Write(Box::new(move |s| f(o(s)))), + } + } +} |