Fix more clippy warnings
This commit is contained in:
parent
489adc1af1
commit
49f7774d66
@ -16,4 +16,5 @@ rust-embed="6.0.0"
|
||||
hex = "0.4.3"
|
||||
serde_json = "1"
|
||||
live-view = { path = "./liveview-rust/" }
|
||||
askama = "0.10.5"
|
||||
# askama = "0.10.5"
|
||||
askama = { git = "https://github.com/djc/askama", rev = "017b590" }
|
||||
|
@ -2,8 +2,6 @@
|
||||
// #![allow(dead_code, unused_imports)]
|
||||
// Enable clippy 'hard mode'
|
||||
#![warn(clippy::all, clippy::pedantic, clippy::nursery)]
|
||||
// Intended behavior (10_f64 as i32)
|
||||
// #![allow(clippy::cast_possible_truncation)]
|
||||
#![allow(
|
||||
// Cannot be fixed
|
||||
clippy::multiple_crate_versions,
|
||||
@ -79,7 +77,7 @@ fn main() -> ProgramResult<()> {
|
||||
Ok(errors::Message::String(s)) => println!("\r{}", s),
|
||||
Ok(errors::Message::Error(e)) => println!("\rError!! {:?}", e),
|
||||
Ok(errors::Message::Terminated) => {
|
||||
panic!("A thread terminated")
|
||||
panic!("A thread terminated");
|
||||
}
|
||||
Ok(errors::Message::InputPrompt(i)) => input_prompt = Some(i),
|
||||
Err(e) => {
|
||||
@ -92,7 +90,7 @@ fn main() -> ProgramResult<()> {
|
||||
if let Some(ref s) = input_prompt {
|
||||
print!("{}: ", s);
|
||||
// We do not care if we can't flush
|
||||
let _ = io::stdout().flush();
|
||||
let _drop = io::stdout().flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
12
src/strip.rs
12
src/strip.rs
@ -56,8 +56,8 @@ impl LedStrip {
|
||||
let num_lights = config.num_lights;
|
||||
let mut ret = Self {
|
||||
adapter,
|
||||
pattern,
|
||||
config,
|
||||
pattern,
|
||||
};
|
||||
ret.set_num_lights(num_lights);
|
||||
Ok(ret)
|
||||
@ -120,7 +120,7 @@ impl LedStrip {
|
||||
if pat.init(self.config.num_lights).is_ok() {
|
||||
self.pattern = pat;
|
||||
} else {
|
||||
let _ = message_tx.send(errors::Message::String(format!(
|
||||
let _result = message_tx.send(errors::Message::String(format!(
|
||||
"Clearing light strip: {:?}",
|
||||
pat
|
||||
)));
|
||||
@ -131,7 +131,7 @@ impl LedStrip {
|
||||
if pat.init(self.config.num_lights).is_ok() {
|
||||
self.pattern = pat;
|
||||
} else {
|
||||
let _ = message_tx.send(errors::Message::String(format!(
|
||||
let _result = message_tx.send(errors::Message::String(format!(
|
||||
"Error initializing pattern: {:?}",
|
||||
pat
|
||||
)));
|
||||
@ -142,7 +142,7 @@ impl LedStrip {
|
||||
}
|
||||
Message::SetTickTime(tick_time_ms) => {
|
||||
if tick_time_ms < MIN_TICK_TIME {
|
||||
let _ = message_tx.send(errors::Message::String(format!(
|
||||
let _result = message_tx.send(errors::Message::String(format!(
|
||||
"Error with tick time: {}",
|
||||
tick_time_ms
|
||||
)));
|
||||
@ -157,7 +157,7 @@ impl LedStrip {
|
||||
if pat.init(self.config.num_lights).is_ok() {
|
||||
self.pattern = Box::new(pat);
|
||||
} else {
|
||||
let _ = message_tx.send(errors::Message::String(String::from(
|
||||
let _result = message_tx.send(errors::Message::String(String::from(
|
||||
"Could not construct clear pattern",
|
||||
)));
|
||||
}
|
||||
@ -174,7 +174,7 @@ impl LedStrip {
|
||||
}
|
||||
|
||||
if exit {
|
||||
let _ = message_tx.send(errors::Message::String(String::from(
|
||||
let _result = message_tx.send(errors::Message::String(String::from(
|
||||
"Exiting as requested",
|
||||
)));
|
||||
process::exit(0);
|
||||
|
@ -22,6 +22,6 @@ pub struct ControlTemplate {
|
||||
}
|
||||
impl live_view::Template for ControlTemplate {
|
||||
fn render(&self) -> Result<String, Box<dyn std::error::Error>> {
|
||||
Ok(<Self as askama::Template>::render(&self)?)
|
||||
Ok(<Self as askama::Template>::render(self)?)
|
||||
}
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ fn change_pattern(
|
||||
}
|
||||
|
||||
fn get_line(message_tx: &Sender<errors::Message>, prompt: &str) -> ProgramResult<String> {
|
||||
let _ = message_tx.send(errors::Message::InputPrompt(String::from(prompt)));
|
||||
let _drop = message_tx.send(errors::Message::InputPrompt(String::from(prompt)));
|
||||
std::io::stdout()
|
||||
.flush()
|
||||
.map_err(|_| ProgramError::UiError(String::from("Could not flush stdout")))?;
|
||||
|
@ -39,7 +39,7 @@ pub async fn start(
|
||||
message_tx: Sender<errors::Message>,
|
||||
strip_tx: Sender<strip::Message>,
|
||||
) -> std::io::Result<()> {
|
||||
let _ = message_tx.send(errors::Message::String(String::from("Starting webui")));
|
||||
let _drop = message_tx.send(errors::Message::String(String::from("Starting webui")));
|
||||
HttpServer::new(move || {
|
||||
App::new()
|
||||
.data(AppState {
|
||||
@ -49,7 +49,7 @@ pub async fn start(
|
||||
web::scope("/api")
|
||||
.app_data(
|
||||
JsonConfig::default().error_handler(|err: JsonPayloadError, _req| {
|
||||
// let _ = message_tx.send(errors::Message::String(format!("JSON error: {:?}", err)));
|
||||
// let _drop = message_tx.send(errors::Message::String(format!("JSON error: {:?}", err)));
|
||||
println!("JSON error: {:?}", err);
|
||||
err.into()
|
||||
}),
|
||||
|
@ -1,9 +1,10 @@
|
||||
<!-- TODO: Do not use .to_string() for comparison -->
|
||||
<!-- TODO: When refreshing, the selected element does not change -->
|
||||
<select rust-input="change-template">
|
||||
{% let selected_name = parameters.get_name() %}
|
||||
{% for name in Parameters::get_names() %}
|
||||
<option value="{{ name }}"
|
||||
{% if name.to_string() == parameters.get_name() -%}
|
||||
<!-- TODO: Do not use .to_string() for comparison -->
|
||||
{% if selected_name == name.to_string() -%}
|
||||
selected="selected"
|
||||
{%- endif -%}
|
||||
>{{ name }}</option>
|
||||
|
Loading…
x
Reference in New Issue
Block a user