Use unstable Crate rustfmt option

This commit is contained in:
Your Name 2021-10-10 16:43:30 +01:00
parent b5b4bf3b41
commit fc5403388f
15 changed files with 62 additions and 57 deletions

View File

@ -1,2 +1,2 @@
# unstable_features = true
# imports_granularity = "Crate"
unstable_features = true
imports_granularity = "Crate"

View File

@ -1,7 +1,5 @@
use serde::Deserialize;
use serde::Serialize;
use std::num::ParseIntError;
use std::str::FromStr;
use serde::{Deserialize, Serialize};
use std::{num::ParseIntError, str::FromStr};
#[derive(Copy, Clone, Debug, PartialEq, Deserialize, Serialize, Default)]
pub struct Rgb(pub u8, pub u8, pub u8);

View File

@ -1,6 +1,5 @@
use core::any::Any;
use std::fmt;
use std::io;
use std::{fmt, io};
pub type ProgramResult<T> = Result<T, ProgramError>;

View File

@ -36,10 +36,12 @@ mod template;
mod ui;
mod webui;
use errors::{ProgramError, ProgramResult};
use std::io;
use std::io::Write;
use std::sync::mpsc::{channel, Sender};
use std::thread;
use std::{
io,
io::Write,
sync::mpsc::{channel, Sender},
thread,
};
use strip::LedStrip;
use ui::console_ui_loop;

View File

@ -1,7 +1,6 @@
use crate::color::Rgb;
use serde::{Deserialize, Serialize};
use std::collections::vec_deque;
use std::iter;
pub mod collide;
pub mod fade;
@ -66,7 +65,7 @@ impl InputRender for Rgb {
impl InputRender for Vec<Rgb> {
fn render(&self, name: &str, _multi_index: Option<usize>) -> String {
self.iter()
.chain(iter::once(&Rgb::default()))
// .chain(iter::once(&Rgb::default()))
.enumerate()
.fold(String::new(), |acc, (i, c)| {
acc + &c.render(name, Some(i)) + "\n"

View File

@ -1,8 +1,7 @@
use super::{FormRender, InputRender, Pattern};
use crate::color::{self, Rgb};
use serde::{Deserialize, Serialize};
use std::collections::vec_deque;
use std::collections::VecDeque;
use std::collections::{vec_deque, VecDeque};
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct CollideParams {

View File

@ -1,9 +1,10 @@
use super::{FormRender, InputRender, Pattern};
use crate::color::{self, merge_colors_u8, Rgb};
use serde::{Deserialize, Serialize};
use std::collections::vec_deque;
use std::collections::VecDeque;
use std::iter;
use std::{
collections::{vec_deque, VecDeque},
iter,
};
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct FadeParams {

View File

@ -1,8 +1,7 @@
use super::{FormRender, InputRender, Pattern};
use crate::color::{self, Rgb};
use serde::{Deserialize, Serialize};
use std::collections::vec_deque;
use std::collections::VecDeque;
use std::collections::{vec_deque, VecDeque};
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct MovingPixelParams {

View File

@ -1,9 +1,11 @@
use super::{FormRender, InputRender, Pattern};
use crate::color::{self, Rgb, RAINBOW};
use serde::{Deserialize, Serialize};
use std::collections::{vec_deque, VecDeque};
use std::convert::TryFrom;
use std::iter;
use std::{
collections::{vec_deque, VecDeque},
convert::TryFrom,
iter,
};
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct MovingRainbowParams {

View File

@ -1,9 +1,10 @@
use super::{FormRender, InputRender, Pattern};
use crate::color::{self, Rgb};
use serde::{Deserialize, Serialize};
use std::collections::vec_deque;
use std::collections::VecDeque;
use std::iter;
use std::{
collections::{vec_deque, VecDeque},
iter,
};
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct OrbParams {

View File

@ -1,8 +1,7 @@
use super::{FormRender, InputRender, Pattern};
use crate::color::{self, Rgb};
use serde::{Deserialize, Serialize};
use std::collections::vec_deque;
use std::collections::VecDeque;
use std::collections::{vec_deque, VecDeque};
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct SolidParams {

View File

@ -1,14 +1,17 @@
use crate::color;
use crate::errors;
use crate::errors::ProgramError;
use crate::pattern::{self, Pattern};
use std::cmp;
use std::ops::Add;
use std::process;
use std::sync::mpsc::{Receiver, Sender};
use std::time::{Duration, Instant};
use ws2818_rgb_led_spi_driver::adapter_gen::Ws28xxAdapter;
use ws2818_rgb_led_spi_driver::adapter_spi::Ws28xxSpiAdapter;
use crate::{
color, errors,
errors::ProgramError,
pattern::{self, Pattern},
};
use std::{
cmp,
ops::Add,
process,
sync::mpsc::{Receiver, Sender},
thread,
time::{Duration, Instant},
};
use ws2818_rgb_led_spi_driver::{adapter_gen::Ws28xxAdapter, adapter_spi::Ws28xxSpiAdapter};
/// Maximum number of lights allowed
const MAX_NUM_LIGHTS: u16 = 128;

View File

@ -1,5 +1,7 @@
use crate::pattern::{FormRender, Parameters};
use crate::strip;
use crate::{
pattern::{FormRender, Parameters},
strip,
};
use std::sync::{mpsc::Sender, Arc, Mutex};
#[derive(askama::Template, Clone, Debug, Default)]

View File

@ -1,10 +1,10 @@
use crate::color::Rgb;
use crate::errors::{self, ProgramError, ProgramResult};
use crate::pattern::{self, Pattern};
use crate::strip;
use std::io;
use std::io::Write;
use std::sync::mpsc::Sender;
use crate::{
color::Rgb,
errors::{self, ProgramError, ProgramResult},
pattern::{self, Pattern},
strip,
};
use std::{io, io::Write, sync::mpsc::Sender};
pub fn console_ui_loop(
message_tx: &Sender<errors::Message>,

View File

@ -1,20 +1,21 @@
use crate::errors;
use crate::pattern;
use crate::strip;
use crate::template::{AppTemplate, ControlTemplate};
use crate::{
errors, pattern, strip,
template::{AppTemplate, ControlTemplate},
};
use actix_web::HttpResponse;
use actix_web_actors::ws;
use live_view::{LiveView, StateSocket, Template};
use actix_web::HttpRequest;
use actix_web::{
error::{ErrorInternalServerError, JsonPayloadError, UrlencodedError},
get, post, web,
web::JsonConfig,
App, HttpServer, Responder, Result,
App, HttpRequest, HttpServer, Responder, Result,
};
use std::{
io,
sync::{mpsc::Sender, Arc, Mutex},
};
use std::io;
use std::sync::{mpsc::Sender, Arc, Mutex};
struct AppState {
strip_tx: Arc<Mutex<Sender<strip::Message>>>,