diff --git a/clap_complete/src/engine/custom.rs b/clap_complete/src/engine/custom.rs index 7813773bb75..20872960daf 100644 --- a/clap_complete/src/engine/custom.rs +++ b/clap_complete/src/engine/custom.rs @@ -5,7 +5,7 @@ use clap::builder::ArgExt; use super::CompletionCandidate; -/// Extend [`Arg`][clap::Arg] with a [`CustomCompleter`] +/// Extend [`Arg`][clap::Arg] with a [`ValueCandidates`] /// /// # Example /// @@ -23,13 +23,13 @@ use super::CompletionCandidate; /// } /// ``` #[derive(Clone)] -pub struct ArgValueCompleter(Arc); +pub struct ArgValueCompleter(Arc); impl ArgValueCompleter { /// Create a new `ArgValueCompleter` with a custom completer pub fn new(completer: C) -> Self where - C: CustomCompleter + 'static, + C: ValueCandidates + 'static, { Self(Arc::new(completer)) } @@ -53,14 +53,14 @@ impl ArgExt for ArgValueCompleter {} /// User-provided completion candidates for an [`Arg`][clap::Arg], see [`ArgValueCompleter`] /// /// This is useful when predefined value hints are not enough. -pub trait CustomCompleter: Send + Sync { +pub trait ValueCandidates: Send + Sync { /// All potential candidates for an argument. /// /// See [`CompletionCandidate`] for more information. fn candidates(&self) -> Vec; } -impl CustomCompleter for F +impl ValueCandidates for F where F: Fn() -> Vec + Send + Sync, { diff --git a/clap_complete/src/engine/mod.rs b/clap_complete/src/engine/mod.rs index c10cf57a6de..4cedd9a7123 100644 --- a/clap_complete/src/engine/mod.rs +++ b/clap_complete/src/engine/mod.rs @@ -9,4 +9,4 @@ mod custom; pub use candidate::CompletionCandidate; pub use complete::complete; pub use custom::ArgValueCompleter; -pub use custom::CustomCompleter; +pub use custom::ValueCandidates; diff --git a/clap_complete/tests/testsuite/engine.rs b/clap_complete/tests/testsuite/engine.rs index fc991258e78..8c6cebe8363 100644 --- a/clap_complete/tests/testsuite/engine.rs +++ b/clap_complete/tests/testsuite/engine.rs @@ -4,7 +4,7 @@ use std::fs; use std::path::Path; use clap::{builder::PossibleValue, Command}; -use clap_complete::engine::{ArgValueCompleter, CompletionCandidate, CustomCompleter}; +use clap_complete::engine::{ArgValueCompleter, CompletionCandidate, ValueCandidates}; use snapbox::assert_data_eq; macro_rules! complete { @@ -596,7 +596,7 @@ fn suggest_custom_arg_value() { #[derive(Debug)] struct MyCustomCompleter {} - impl CustomCompleter for MyCustomCompleter { + impl ValueCandidates for MyCustomCompleter { fn candidates(&self) -> Vec { vec![ CompletionCandidate::new("custom1"),