Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Few nits and clippy warnings #787

Merged
merged 7 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cursive-core/src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl CellWidth {
match width {
1 => CellWidth::Single,
2 => CellWidth::Double,
_ => panic!("expected width of 1 or 2 only."),
n => panic!("expected width of 1 or 2 only. Got {n}."),
}
}

Expand Down
4 changes: 2 additions & 2 deletions cursive-core/src/utils/lines/spans/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fn input() -> StyledString {
}

#[test]
fn test_replacement_have_width_1() {
fn test_replacement_char_has_width_1() {
use unicode_width::UnicodeWidthStr;

let replacement_char = "\u{FFFD}";
Expand Down Expand Up @@ -52,7 +52,7 @@ fn test_control_chars_have_width_1() {
"it's supposed to be a string of 1 char"
);
let unicode_escape = format!("\\u{{{:04X}}}", c.chars().last().unwrap() as u32);
debug_assert_eq!(
assert_eq!(
width, 1,
"Width of control character {} is not 1",
unicode_escape
Expand Down
4 changes: 2 additions & 2 deletions cursive-core/src/views/dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ impl crate::builder::Resolvable for DialogFocus {
// The config can be either:
// A string: content
// An object: button: i
if let Ok(string) = context.resolve::<String>(&config) {
if let Ok(string) = context.resolve::<String>(config) {
if string == "Content" || string == "content" {
return Some(DialogFocus::Content);
} else {
return None;
}
}

if let Ok(obj) = context.resolve::<Object>(&config) {
if let Ok(obj) = context.resolve::<Object>(config) {
let (key, value) = obj.iter().next()?;

if key != "Button" {
Expand Down
8 changes: 4 additions & 4 deletions cursive-macros/src/builder/recipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ impl Variable {
};

// Some types have special handling
if let Some(_) = is_option_type(&field.ty) {
if is_option_type(&field.ty).is_some() {
consumer = Consumer::Opt(Box::new(consumer));
}

Expand Down Expand Up @@ -558,7 +558,7 @@ impl syn::parse::Parse for RecipeAttributes {
find_parameters(&base, &mut base_parameters);

// Compute name and parameters from the expression.
let mut name = base_default_name(&base).unwrap_or_else(String::new);
let mut name = base_default_name(&base).unwrap_or_default();

// We can't parse this as a regular nested meta.
// Parse it as a list of `key = value` items.
Expand All @@ -573,11 +573,11 @@ impl syn::parse::Parse for RecipeAttributes {
}
}

return Ok(RecipeAttributes {
Ok(RecipeAttributes {
base,
base_parameters,
name,
});
})
}
}

Expand Down
2 changes: 1 addition & 1 deletion cursive/examples/autocomplete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use cursive::Cursive;
// This example shows a way to implement a (Google-like) autocomplete search box.
// Try entering "tok"!

static CITIES: &'static str = include_str!("assets/cities.txt");
static CITIES: &str = include_str!("assets/cities.txt");

fn main() {
let mut siv = cursive::default();
Expand Down
4 changes: 1 addition & 3 deletions cursive/examples/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ fn main() {
// Just a regular callback for EditView::on_edit
fn on_edit_callback(siv: &mut cursive::Cursive, text: &str, cursor: usize) {
siv.call_on_name("status", |v: &mut TextView| {
let spaces: String = std::iter::repeat(" ")
.take(cursor + "You wrote `".len())
.collect();
let spaces: String = " ".repeat(cursor + "You wrote `".len());
v.set_content(format!("You wrote `{text}`\n{spaces}^"));
})
.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion cursive/examples/select_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// cargo test --example select_test -- --nocapture

fn main() {
print!("To run this example call:\n$ cargo test --bin select_test -- --nocapture\n");
println!("To run this example call:\n$ cargo test --example select_test -- --nocapture");
}

#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion cursive/src/backends/puppet/observed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ mod tests {
use crate::backends::puppet::DEFAULT_OBSERVED_STYLE;

/// Expecting fake_screen to be square, # will be replaced with blank.
fn get_observed_screen(fake_screen: &Vec<&str>) -> ObservedScreen {
fn get_observed_screen(fake_screen: &[&str]) -> ObservedScreen {
let observed_style: Arc<ObservedStyle> = Arc::new(DEFAULT_OBSERVED_STYLE.clone());

let height = fake_screen.len();
Expand Down