Skip to content

Commit 5029bb3

Browse files
committed
chore: Avoid using gen for rust 2024 preserved keyword
1 parent 8a1d59b commit 5029bb3

File tree

8 files changed

+34
-19
lines changed

8 files changed

+34
-19
lines changed

clap_complete/examples/completion-derive.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,13 @@ struct ValueHintOpt {
6666
email: Option<String>,
6767
}
6868

69-
fn print_completions<G: Generator>(gen: G, cmd: &mut Command) {
70-
generate(gen, cmd, cmd.get_name().to_string(), &mut io::stdout());
69+
fn print_completions<G: Generator>(generator: G, cmd: &mut Command) {
70+
generate(
71+
generator,
72+
cmd,
73+
cmd.get_name().to_string(),
74+
&mut io::stdout(),
75+
);
7176
}
7277

7378
fn main() {

clap_complete/examples/completion.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,13 @@ fn build_cli() -> Command {
9494
.subcommand(value_hint_command)
9595
}
9696

97-
fn print_completions<G: Generator>(gen: G, cmd: &mut Command) {
98-
generate(gen, cmd, cmd.get_name().to_string(), &mut io::stdout());
97+
fn print_completions<G: Generator>(generator: G, cmd: &mut Command) {
98+
generate(
99+
generator,
100+
cmd,
101+
cmd.get_name().to_string(),
102+
&mut io::stdout(),
103+
);
99104
}
100105

101106
fn main() {

clap_complete/examples/exhaustive.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@ fn main() {
1919
println!("{matches:?}");
2020
}
2121

22-
fn print_completions<G: Generator>(gen: G, cmd: &mut clap::Command) {
23-
generate(gen, cmd, cmd.get_name().to_string(), &mut std::io::stdout());
22+
fn print_completions<G: Generator>(generator: G, cmd: &mut clap::Command) {
23+
generate(
24+
generator,
25+
cmd,
26+
cmd.get_name().to_string(),
27+
&mut std::io::stdout(),
28+
);
2429
}
2530

2631
const EMPTY: [&str; 0] = [];

clap_complete/src/aot/generator/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ pub trait Generator {
197197
/// }
198198
/// ```
199199
pub fn generate_to<G, S, T>(
200-
gen: G,
200+
generator: G,
201201
cmd: &mut Command,
202202
bin_name: S,
203203
out_dir: T,
@@ -210,12 +210,12 @@ where
210210
cmd.set_bin_name(bin_name);
211211

212212
let out_dir = PathBuf::from(out_dir.into());
213-
let file_name = gen.file_name(cmd.get_bin_name().unwrap());
213+
let file_name = generator.file_name(cmd.get_bin_name().unwrap());
214214

215215
let path = out_dir.join(file_name);
216216
let mut file = File::create(&path)?;
217217

218-
_generate::<G>(gen, cmd, &mut file);
218+
_generate::<G>(generator, cmd, &mut file);
219219
Ok(path)
220220
}
221221

@@ -254,13 +254,13 @@ where
254254
/// ```console
255255
/// $ myapp generate-bash-completions > /usr/share/bash-completion/completions/myapp.bash
256256
/// ```
257-
pub fn generate<G, S>(gen: G, cmd: &mut Command, bin_name: S, buf: &mut dyn Write)
257+
pub fn generate<G, S>(generator: G, cmd: &mut Command, bin_name: S, buf: &mut dyn Write)
258258
where
259259
G: Generator,
260260
S: Into<String>,
261261
{
262262
cmd.set_bin_name(bin_name);
263-
_generate::<G>(gen, cmd, buf);
263+
_generate::<G>(generator, cmd, buf);
264264
}
265265

266266
fn _generate<G: Generator>(gen: G, cmd: &mut Command, buf: &mut dyn Write) {

clap_complete/src/aot/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
//! )
3434
//! }
3535
//!
36-
//! fn print_completions<G: Generator>(gen: G, cmd: &mut Command) {
37-
//! generate(gen, cmd, cmd.get_name().to_string(), &mut io::stdout());
36+
//! fn print_completions<G: Generator>(generator: G, cmd: &mut Command) {
37+
//! generate(generator, cmd, cmd.get_name().to_string(), &mut io::stdout());
3838
//! }
3939
//!
4040
//! fn main() {

clap_complete/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
//! .value_parser(value_parser!(Shell)))
3232
//! }
3333
//!
34-
//! fn print_completions<G: Generator>(gen: G, cmd: &mut Command) {
35-
//! generate(gen, cmd, cmd.get_name().to_string(), &mut io::stdout());
34+
//! fn print_completions<G: Generator>(generator: G, cmd: &mut Command) {
35+
//! generate(generator, cmd, cmd.get_name().to_string(), &mut io::stdout());
3636
//! }
3737
//!
3838
//! fn main() {

clap_complete/tests/testsuite/common.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -286,12 +286,12 @@ pub(crate) fn subcommand_last(name: &'static str) -> clap::Command {
286286

287287
pub(crate) fn assert_matches(
288288
expected: impl IntoData,
289-
gen: impl clap_complete::Generator,
289+
generator: impl clap_complete::Generator,
290290
mut cmd: clap::Command,
291291
name: &'static str,
292292
) {
293293
let mut buf = vec![];
294-
clap_complete::generate(gen, &mut cmd, name, &mut buf);
294+
clap_complete::generate(generator, &mut cmd, name, &mut buf);
295295

296296
snapbox::Assert::new()
297297
.action_env(snapbox::assert::DEFAULT_ACTION_ENV)

clap_complete_nushell/tests/common.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,12 @@ pub(crate) fn value_hint_command(name: &'static str) -> Command {
246246

247247
pub(crate) fn assert_matches(
248248
expected: impl IntoData,
249-
gen: impl clap_complete::Generator,
249+
generator: impl clap_complete::Generator,
250250
mut cmd: Command,
251251
name: &'static str,
252252
) {
253253
let mut buf = vec![];
254-
clap_complete::generate(gen, &mut cmd, name, &mut buf);
254+
clap_complete::generate(generator, &mut cmd, name, &mut buf);
255255

256256
snapbox::Assert::new()
257257
.action_env(snapbox::assert::DEFAULT_ACTION_ENV)

0 commit comments

Comments
 (0)