Skip to content

Commit 14ba9b9

Browse files
committed
Upgrade rust edition
1 parent fa11422 commit 14ba9b9

File tree

4 files changed

+16
-24
lines changed

4 files changed

+16
-24
lines changed

.vscode/settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"rust-analyzer.checkOnSave.command": "clippy"
3-
}
2+
"rust-analyzer.cargo.features": "all"
3+
}

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
name = "dialoguer"
33
description = "A command line prompting library."
44
version = "0.10.4"
5-
edition = "2018"
5+
edition = "2021"
66
authors = [
77
"Armin Ronacher <armin.ronacher@active-4.com>",
88
"Pavan Kumar Sunkara <pavan.sss1991@gmail.com>"
99
]
1010
keywords = ["cli", "menu", "prompt"]
1111
categories = ["command-line-interface"]
1212
license = "MIT"
13-
homepage = "https://github.com/mitsuhiko/dialoguer"
14-
repository = "https://github.com/mitsuhiko/dialoguer"
13+
homepage = "https://github.com/console-rs/dialoguer"
14+
repository = "https://github.com/console-rs/dialoguer"
1515
documentation = "https://docs.rs/dialoguer"
1616
readme = "README.md"
1717

src/prompts/password.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type PasswordValidatorCallback<'a> = Box<dyn Fn(&String) -> Option<String> + 'a>
1515
/// ## Example usage
1616
///
1717
/// ```rust,no_run
18-
/// # fn test() -> Result<(), Box<std::error::Error>> {
18+
/// # fn test() -> Result<(), Box<dyn std::error::Error>> {
1919
/// use dialoguer::Password;
2020
///
2121
/// let password = Password::new().with_prompt("New Password")

src/theme.rs

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ pub trait Theme {
222222
write!(f, "{} ", if active { ">" } else { " " })?;
223223

224224
if highlight_matches {
225-
if let Some((_score, indices)) = matcher.fuzzy_indices(text, &search_term) {
226-
for (idx, c) in text.chars().into_iter().enumerate() {
225+
if let Some((_score, indices)) = matcher.fuzzy_indices(text, search_term) {
226+
for (idx, c) in text.chars().enumerate() {
227227
if indices.contains(&idx) {
228228
write!(f, "{}", style(c).for_stderr().bold())?;
229229
} else {
@@ -248,7 +248,7 @@ pub trait Theme {
248248
cursor_pos: usize,
249249
) -> fmt::Result {
250250
if !prompt.is_empty() {
251-
write!(f, "{} ", prompt,)?;
251+
write!(f, "{} ", prompt)?;
252252
}
253253

254254
if cursor_pos < search_term.len() {
@@ -258,7 +258,7 @@ pub trait Theme {
258258
write!(f, "{}{}{}", st_head, st_cursor, st_tail)
259259
} else {
260260
let cursor = "|".to_string();
261-
write!(f, "{}{}", search_term.to_string(), cursor)
261+
write!(f, "{}{}", search_term, cursor)
262262
}
263263
}
264264
}
@@ -636,8 +636,8 @@ impl Theme for ColorfulTheme {
636636
)?;
637637

638638
if highlight_matches {
639-
if let Some((_score, indices)) = matcher.fuzzy_indices(text, &search_term) {
640-
for (idx, c) in text.chars().into_iter().enumerate() {
639+
if let Some((_score, indices)) = matcher.fuzzy_indices(text, search_term) {
640+
for (idx, c) in text.chars().enumerate() {
641641
if indices.contains(&idx) {
642642
if active {
643643
write!(
@@ -649,12 +649,10 @@ impl Theme for ColorfulTheme {
649649
} else {
650650
write!(f, "{}", self.fuzzy_match_highlight_style.apply_to(c))?;
651651
}
652+
} else if active {
653+
write!(f, "{}", self.active_item_style.apply_to(c))?;
652654
} else {
653-
if active {
654-
write!(f, "{}", self.active_item_style.apply_to(c))?;
655-
} else {
656-
write!(f, "{}", c)?;
657-
}
655+
write!(f, "{}", c)?;
658656
}
659657
}
660658

@@ -696,13 +694,7 @@ impl Theme for ColorfulTheme {
696694
)
697695
} else {
698696
let cursor = self.fuzzy_cursor_style.apply_to(" ");
699-
write!(
700-
f,
701-
"{} {}{}",
702-
&self.prompt_suffix,
703-
search_term.to_string(),
704-
cursor
705-
)
697+
write!(f, "{} {}{}", &self.prompt_suffix, search_term, cursor)
706698
}
707699
}
708700
}

0 commit comments

Comments
 (0)