From 62712219406ef95d83060bf637c0fa831bcc30d8 Mon Sep 17 00:00:00 2001 From: Aster Date: Thu, 10 Feb 2022 04:02:09 +0800 Subject: [PATCH] Fix format and clippy --- rustfmt.toml | 8 ++++++++ src/builder.rs | 12 +++++------- src/cli/config/mod.rs | 1 - src/cli/mod.rs | 32 +++++++++++++------------------- src/server/mod.rs | 3 +-- 5 files changed, 27 insertions(+), 29 deletions(-) create mode 100644 rustfmt.toml diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 000000000..9071fb4b5 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,8 @@ +version = "Two" +edition = "2018" + +imports_granularity = "Crate" +#use_small_heuristics = "Max" +#control_brace_style = "ClosingNextLine" +normalize_comments = true +format_code_in_doc_comments = true \ No newline at end of file diff --git a/src/builder.rs b/src/builder.rs index 257072a6a..f3090f85d 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -11,13 +11,11 @@ use std::{ use wasm_bindgen_cli_support::Bindgen; pub fn build(config: &CrateConfig) -> Result<()> { - /* - [1] Build the project with cargo, generating a wasm32-unknown-unknown target (is there a more specific, better target to leverage?) - [2] Generate the appropriate build folders - [3] Wasm-bindgen the .wasm fiile, and move it into the {builddir}/modules/xxxx/xxxx_bg.wasm - [4] Wasm-opt the .wasm file with whatever optimizations need to be done - [5] Link up the html page to the wasm module - */ + // [1] Build the project with cargo, generating a wasm32-unknown-unknown target (is there a more specific, better target to leverage?) + // [2] Generate the appropriate build folders + // [3] Wasm-bindgen the .wasm fiile, and move it into the {builddir}/modules/xxxx/xxxx_bg.wasm + // [4] Wasm-opt the .wasm file with whatever optimizations need to be done + // [5] Link up the html page to the wasm module let CrateConfig { out_dir, diff --git a/src/cli/config/mod.rs b/src/cli/config/mod.rs index 3cbf368e0..6d672b7a5 100644 --- a/src/cli/config/mod.rs +++ b/src/cli/config/mod.rs @@ -1,6 +1,5 @@ use super::*; - /// Build the Rust WASM app and all of its assets. #[derive(Clone, Debug, Deserialize, Subcommand)] #[clap(name = "config")] diff --git a/src/cli/mod.rs b/src/cli/mod.rs index 8ec374933..1b5ba0be7 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -6,30 +6,25 @@ pub mod create; pub mod serve; pub mod translate; -use crate::custom_error; -use crate::{cfg::ConfigOptsBuild, gen_page}; -use crate::{cfg::ConfigOptsServe, server, CrateConfig}; -use crate::{error::Result, Error}; -use clap::Parser; -use html_parser::Dom; -use html_parser::Element; -use html_parser::Node; +use crate::{ + cfg::{ConfigOptsBuild, ConfigOptsServe}, + custom_error, + error::Result, + gen_page, server, CrateConfig, Error, +}; +use clap::{Parser, Subcommand}; +use html_parser::{Dom, Element, Node}; use regex::Regex; use serde::Deserialize; -use std::fmt::{Display, Formatter}; -use std::fs::File; -use std::io::Read; -use std::process::exit; use std::{ - fs::remove_dir_all, - process::{Command, Stdio}, + fmt::{Display, Formatter}, + fs::{remove_dir_all, File}, + io::{Read, Write}, + path::PathBuf, + process::{exit, Command, Stdio}, }; -use std::{io::Write, path::PathBuf}; -use clap::{Subcommand}; /// Build, bundle, & ship your Dioxus app. -/// -/// #[derive(Parser)] #[clap(name = "dioxus")] pub struct Cli { @@ -39,7 +34,6 @@ pub struct Cli { /// Enable verbose logging. #[clap(short)] pub v: bool, - // // // note: dioxus is still roughly compatible with trunk // /// Path to the Trunk config file [default: Trunk.toml] // #[clap(long, parse(from_os_str), env = "TRUNK_CONFIG")] diff --git a/src/server/mod.rs b/src/server/mod.rs index f312e07c2..38e37d60b 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -10,8 +10,7 @@ use notify::{RecommendedWatcher, Watcher}; use std::{path::PathBuf, sync::Arc}; use tower_http::services::ServeDir; -use crate::Result; -use crate::{builder, serve::Serve, CrateConfig}; +use crate::{builder, serve::Serve, CrateConfig, Result}; use tokio::sync::broadcast; struct WsRelodState {