// In-memory backend used by `Clipboard::new_in_memory` for tests and
// headless hosts where the real OS clipboard isn't reachable.
//
// Not thread-safe. Concurrent `set_text` from multiple tasks just races
// — last writer wins. That matches the contract in `spec.mbt` (no
// internal mutex).
///|
priv struct InMemoryBackend {
mut current : String?
}
///|
fn InMemoryBackend::new() -> InMemoryBackend {
{ current: None }
}
///|
impl Backend for InMemoryBackend with fn get_text(self) {
match self.current {
Some(s) => s
None => raise Empty
}
}
///|
impl Backend for InMemoryBackend with fn set_text(self, text) {
self.current = Some(text)
}