From 72fea42c17a166b1cf90e03b3114b954fb9caa25 Mon Sep 17 00:00:00 2001 From: Igor Date: Mon, 14 Oct 2024 20:06:40 +0400 Subject: [PATCH] chore: where possible replace `async-trait` with native async trait support in 1.75+ (#197) Reduce usage of the async-trait crate where possible, using the async_fn_in_trait native feature in 1.75+. --- brush-shell/src/shell_factory.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/brush-shell/src/shell_factory.rs b/brush-shell/src/shell_factory.rs index 1a770ac8..58d70c04 100644 --- a/brush-shell/src/shell_factory.rs +++ b/brush-shell/src/shell_factory.rs @@ -50,6 +50,30 @@ impl AsMut for StubShell { } } +pub(crate) struct RustylineShellFactory; + +impl ShellFactory for RustylineShellFactory { + #[cfg(all(feature = "rustyline", any(windows, unix)))] + type ShellType = brush_interactive::RustylineShell; + #[cfg(any(not(feature = "rustyline"), not(any(windows, unix))))] + type ShellType = StubShell; + + #[allow(unused)] + async fn create( + &self, + options: &brush_interactive::Options, + ) -> Result { + #[cfg(all(feature = "rustyline", any(windows, unix)))] + { + brush_interactive::RustylineShell::new(options).await + } + #[cfg(any(not(feature = "rustyline"), not(any(windows, unix))))] + { + Err(brush_interactive::ShellError::InputBackendNotSupported) + } + } +} + pub(crate) struct ReedlineShellFactory; impl ShellFactory for ReedlineShellFactory {