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

examples: run clippy and fix issues #58

Closed
wants to merge 1 commit into from
Closed
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 examples/256_colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@ fn main() {
fn glow(c: u8, light_bg: bool) {
let base = if light_bg { Color::Black } else { Color::White };
let style = base.on(Color::Fixed(c));
print!("{}", style.paint(&format!(" {:3} ", c)));
print!("{}", style.paint(&format!(" {c:3} ")));
}
5 changes: 4 additions & 1 deletion examples/basic_colors.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use nu_ansi_term::{Color::*, Style};
use nu_ansi_term::{
Color::{Black, Blue, Cyan, Green, Purple, Red, White, Yellow},
Style,
};

// This example prints out the 16 basic colors.

Expand Down
8 changes: 4 additions & 4 deletions examples/gradient_colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ fn main() {
let gradient3 = gradient.reverse();

let build_fg = gradient.build(text, TargetGround::Foreground);
println!("{}", build_fg);
println!("{build_fg}");
let build_bg = gradient.build(text, TargetGround::Background);
println!("{}", build_bg);
println!("{build_bg}");
let bgt = build_all_gradient_text(text, gradient, gradient2);
println!("{}", bgt);
println!("{bgt}");
let bgt2 = build_all_gradient_text(text, gradient, gradient3);
println!("{}", bgt2);
println!("{bgt2}");

println!(
"{}",
Expand Down
2 changes: 1 addition & 1 deletion examples/hyperlink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ fn main() {
.paint("Link to example.com")
.hyperlink("https://example.com");

println!("{}", link);
println!("{link}");
sleep(sleep_ms);
}
6 changes: 3 additions & 3 deletions examples/may_sleep/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ pub fn parse_cmd_args() -> Option<u16> {
.unwrap_or(String::from("5000u16"))
.parse::<u16>()
.ok()
.and_then(|parsed| {
.map(|parsed| {
skip_next = true;
Some(parsed)
parsed
});
}
_ => {}
Expand All @@ -29,7 +29,7 @@ pub fn parse_cmd_args() -> Option<u16> {

pub fn sleep(sleep_ms: Option<u16>) {
if let Some(sleep_ms) = sleep_ms {
let sleep_ms = std::time::Duration::from_millis(sleep_ms as u64);
let sleep_ms = std::time::Duration::from_millis(u64::from(sleep_ms));
std::thread::sleep(sleep_ms);
}
}
5 changes: 1 addition & 4 deletions examples/title.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ fn main() {

let sleep_ms = parse_cmd_args();
let title = AnsiGenericString::title("My Title");
println!(
"{}Terminal title set for the next {:?} milliseconds",
title, sleep_ms
);
println!("{title}Terminal title set for the next {sleep_ms:?} milliseconds");

// sleep because often prompts change this before you can see
// the results
Expand Down
Loading