Skip to content

Commit

Permalink
Upgrade rust edition
Browse files Browse the repository at this point in the history
  • Loading branch information
pksunkara committed Apr 7, 2023
1 parent fa11422 commit 14ba9b9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .vscode/settings.json
@@ -1,3 +1,3 @@
{
"rust-analyzer.checkOnSave.command": "clippy"
}
"rust-analyzer.cargo.features": "all"
}
6 changes: 3 additions & 3 deletions Cargo.toml
Expand Up @@ -2,16 +2,16 @@
name = "dialoguer"
description = "A command line prompting library."
version = "0.10.4"
edition = "2018"
edition = "2021"
authors = [
"Armin Ronacher <armin.ronacher@active-4.com>",
"Pavan Kumar Sunkara <pavan.sss1991@gmail.com>"
]
keywords = ["cli", "menu", "prompt"]
categories = ["command-line-interface"]
license = "MIT"
homepage = "https://github.com/mitsuhiko/dialoguer"
repository = "https://github.com/mitsuhiko/dialoguer"
homepage = "https://github.com/console-rs/dialoguer"
repository = "https://github.com/console-rs/dialoguer"
documentation = "https://docs.rs/dialoguer"
readme = "README.md"

Expand Down
2 changes: 1 addition & 1 deletion src/prompts/password.rs
Expand Up @@ -15,7 +15,7 @@ type PasswordValidatorCallback<'a> = Box<dyn Fn(&String) -> Option<String> + 'a>
/// ## Example usage
///
/// ```rust,no_run
/// # fn test() -> Result<(), Box<std::error::Error>> {
/// # fn test() -> Result<(), Box<dyn std::error::Error>> {
/// use dialoguer::Password;
///
/// let password = Password::new().with_prompt("New Password")
Expand Down
28 changes: 10 additions & 18 deletions src/theme.rs
Expand Up @@ -222,8 +222,8 @@ pub trait Theme {
write!(f, "{} ", if active { ">" } else { " " })?;

if highlight_matches {
if let Some((_score, indices)) = matcher.fuzzy_indices(text, &search_term) {
for (idx, c) in text.chars().into_iter().enumerate() {
if let Some((_score, indices)) = matcher.fuzzy_indices(text, search_term) {
for (idx, c) in text.chars().enumerate() {
if indices.contains(&idx) {
write!(f, "{}", style(c).for_stderr().bold())?;
} else {
Expand All @@ -248,7 +248,7 @@ pub trait Theme {
cursor_pos: usize,
) -> fmt::Result {
if !prompt.is_empty() {
write!(f, "{} ", prompt,)?;
write!(f, "{} ", prompt)?;
}

if cursor_pos < search_term.len() {
Expand All @@ -258,7 +258,7 @@ pub trait Theme {
write!(f, "{}{}{}", st_head, st_cursor, st_tail)
} else {
let cursor = "|".to_string();
write!(f, "{}{}", search_term.to_string(), cursor)
write!(f, "{}{}", search_term, cursor)
}
}
}
Expand Down Expand Up @@ -636,8 +636,8 @@ impl Theme for ColorfulTheme {
)?;

if highlight_matches {
if let Some((_score, indices)) = matcher.fuzzy_indices(text, &search_term) {
for (idx, c) in text.chars().into_iter().enumerate() {
if let Some((_score, indices)) = matcher.fuzzy_indices(text, search_term) {
for (idx, c) in text.chars().enumerate() {
if indices.contains(&idx) {
if active {
write!(
Expand All @@ -649,12 +649,10 @@ impl Theme for ColorfulTheme {
} else {
write!(f, "{}", self.fuzzy_match_highlight_style.apply_to(c))?;
}
} else if active {
write!(f, "{}", self.active_item_style.apply_to(c))?;
} else {
if active {
write!(f, "{}", self.active_item_style.apply_to(c))?;
} else {
write!(f, "{}", c)?;
}
write!(f, "{}", c)?;
}
}

Expand Down Expand Up @@ -696,13 +694,7 @@ impl Theme for ColorfulTheme {
)
} else {
let cursor = self.fuzzy_cursor_style.apply_to(" ");
write!(
f,
"{} {}{}",
&self.prompt_suffix,
search_term.to_string(),
cursor
)
write!(f, "{} {}{}", &self.prompt_suffix, search_term, cursor)
}
}
}
Expand Down

0 comments on commit 14ba9b9

Please sign in to comment.