diff options
author | Robin Krahl <robin.krahl@ireas.org> | 2019-01-11 00:41:59 +0000 |
---|---|---|
committer | Robin Krahl <robin.krahl@ireas.org> | 2019-01-11 01:46:50 +0100 |
commit | 3efbb1ddc8b85f85621db9b37a0980ec88d2386d (patch) | |
tree | b2d029ba4b8bf83fecb6f4e7cef090cbd562025f /src/backends | |
parent | 27834815893eca768f64c4fb9c5a85d42dea60e6 (diff) | |
download | dialog-rs-3efbb1ddc8b85f85621db9b37a0980ec88d2386d.tar.gz dialog-rs-3efbb1ddc8b85f85621db9b37a0980ec88d2386d.tar.bz2 |
Return Box<dyn Backend> in default_backend()
This patch refactors the default_backend function to return a Box<dyn
Backend> instead of impl Backend. This will allow us to dynamically
choose the backend implementation in a future patch. To keep the
current interface, we change show_with to accept both a reference to a
backend instance as well as a reference to a boxed backend instance.
This also means we have to implement AsRef<Self> for the backend
structs.
Diffstat (limited to 'src/backends')
-rw-r--r-- | src/backends/dialog.rs | 6 | ||||
-rw-r--r-- | src/backends/zenity.rs | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/backends/dialog.rs b/src/backends/dialog.rs index 939b8f3..6f078e6 100644 --- a/src/backends/dialog.rs +++ b/src/backends/dialog.rs @@ -77,6 +77,12 @@ impl Dialog { } } +impl AsRef<Dialog> for Dialog { + fn as_ref(&self) -> &Self { + self + } +} + fn require_success(status: process::ExitStatus) -> Result<()> { if status.success() { Ok(()) diff --git a/src/backends/zenity.rs b/src/backends/zenity.rs index a90c3da..4bf862b 100644 --- a/src/backends/zenity.rs +++ b/src/backends/zenity.rs @@ -88,6 +88,12 @@ impl Zenity { } } +impl AsRef<Zenity> for Zenity { + fn as_ref(&self) -> &Self { + self + } +} + fn require_success(status: process::ExitStatus) -> Result<()> { if status.success() { Ok(()) |