refactor: rust nightly format (#197)

* chore: turn on group format

* turn on nightly fmt
docs-add-demo
Meng Zhang 2023-06-05 14:17:07 -07:00 committed by GitHub
parent f4442b104f
commit 272dde9769
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 38 additions and 38 deletions

View File

@ -31,12 +31,11 @@ jobs:
- name: Install Rust - name: Install Rust
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
with: with:
toolchain: stable toolchain: nightly
target: ${{ matrix.target }} components: rustfmt
components: rustfmt, clippy
- name: Cargo fmt - name: Cargo fmt
run: cargo fmt --check run: cargo +nightly fmt --check
release-binary: release-binary:
needs: tests needs: tests

3
.rustfmt.toml Normal file
View File

@ -0,0 +1,3 @@
reorder_imports = true
imports_granularity = "crate"
group_imports = "StdExternalCrate"

View File

@ -1,7 +1,7 @@
use std::{env, path::PathBuf};
use cmake::Config; use cmake::Config;
use rust_cxx_cmake_bridge::read_cmake_generated; use rust_cxx_cmake_bridge::read_cmake_generated;
use std::env;
use std::path::PathBuf;
fn main() { fn main() {
// Tell cargo to invalidate the built crate whenever the wrapper changes // Tell cargo to invalidate the built crate whenever the wrapper changes

View File

@ -1,5 +1,4 @@
use std::io::Write; use std::{io::Write, path::PathBuf};
use std::path::PathBuf;
// ## lib_name: "protobufd" // ## lib_name: "protobufd"
// ## dir: "..../api_circuits/target/debug/build/lib-circuits-wrapper-49025516ce40925e/out/build/_deps/protobuf_fetch-build" // ## dir: "..../api_circuits/target/debug/build/lib-circuits-wrapper-49025516ce40925e/out/build/_deps/protobuf_fetch-build"

View File

@ -1,9 +1,12 @@
use std::{
fs,
io::{BufWriter, Write},
sync::Mutex,
};
use chrono::Utc; use chrono::Utc;
use lazy_static::lazy_static; use lazy_static::lazy_static;
use serde::Serialize; use serde::Serialize;
use std::fs;
use std::io::{BufWriter, Write};
use std::sync::Mutex;
lazy_static! { lazy_static! {
static ref WRITER: Mutex<BufWriter<fs::File>> = { static ref WRITER: Mutex<BufWriter<fs::File>> = {

View File

@ -1,7 +1,4 @@
use std::cell::Cell; use std::{cell::Cell, env, path::PathBuf, sync::Mutex};
use std::env;
use std::path::PathBuf;
use std::sync::Mutex;
use lazy_static::lazy_static; use lazy_static::lazy_static;

View File

@ -1,8 +1,7 @@
use std::{collections::HashMap, fs, path::Path};
use anyhow::Result; use anyhow::Result;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::fs;
use std::path::Path;
use tabby_common::path::ModelDir; use tabby_common::path::ModelDir;
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]

View File

@ -1,16 +1,12 @@
mod cache_info; mod cache_info;
use std::cmp; use std::{cmp, fs, io::Write, path::Path};
use std::fs;
use std::io::Write;
use std::path::Path;
use cache_info::CacheInfo;
use futures_util::StreamExt; use futures_util::StreamExt;
use indicatif::{ProgressBar, ProgressStyle}; use indicatif::{ProgressBar, ProgressStyle};
use tabby_common::path::ModelDir; use tabby_common::path::ModelDir;
use cache_info::CacheInfo;
impl CacheInfo { impl CacheInfo {
async fn download(&mut self, model_id: &str, path: &str, prefer_local_file: bool) { async fn download(&mut self, model_id: &str, path: &str, prefer_local_file: bool) {
// Create url. // Create url.

View File

@ -1,7 +1,8 @@
mod repository; mod repository;
use job_scheduler::{Job, JobScheduler};
use std::time::Duration; use std::time::Duration;
use job_scheduler::{Job, JobScheduler};
use tracing::info; use tracing::info;
pub fn scheduler() { pub fn scheduler() {

View File

@ -1,13 +1,11 @@
use std::path::PathBuf; use std::{path::PathBuf, process::Command};
use std::process::Command;
use filenamify::filenamify;
use tabby_common::{ use tabby_common::{
config::{Config, Repository}, config::{Config, Repository},
path::repositories_dir, path::repositories_dir,
}; };
use filenamify::filenamify;
trait ConfigExt { trait ConfigExt {
fn sync_repositories(&self); fn sync_repositories(&self);
} }
@ -71,11 +69,13 @@ pub fn sync_repositories() {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use tabby_common::{
config::{Config, Repository},
path::set_tabby_root,
};
use temp_testdir::*; use temp_testdir::*;
use tabby_common::config::{Config, Repository}; use super::*;
use tabby_common::path::set_tabby_root;
#[test] #[test]
fn it_works() { fn it_works() {

View File

@ -1,10 +1,10 @@
use std::{path::Path, sync::Arc};
use axum::{extract::State, Json}; use axum::{extract::State, Json};
use ctranslate2_bindings::{ use ctranslate2_bindings::{
TextInferenceEngine, TextInferenceEngineCreateOptionsBuilder, TextInferenceOptionsBuilder, TextInferenceEngine, TextInferenceEngineCreateOptionsBuilder, TextInferenceOptionsBuilder,
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::path::Path;
use std::sync::Arc;
use strfmt::{strfmt, strfmt_builder}; use strfmt::{strfmt, strfmt_builder};
use tabby_common::{events, path::ModelDir}; use tabby_common::{events, path::ModelDir};
use utoipa::ToSchema; use utoipa::ToSchema;

View File

@ -1,6 +1,7 @@
use std::collections::HashMap;
use lazy_static::lazy_static; use lazy_static::lazy_static;
use regex::Regex; use regex::Regex;
use std::collections::HashMap;
lazy_static! { lazy_static! {
static ref DEFAULT: Regex = Regex::new(r"(?m)\n\n").unwrap(); static ref DEFAULT: Regex = Regex::new(r"(?m)\n\n").unwrap();

View File

@ -2,18 +2,20 @@ mod admin;
mod completions; mod completions;
mod events; mod events;
use crate::Cli;
use axum::{routing, Router, Server};
use clap::{error::ErrorKind, Args, CommandFactory};
use std::{ use std::{
net::{Ipv4Addr, SocketAddr}, net::{Ipv4Addr, SocketAddr},
sync::Arc, sync::Arc,
}; };
use axum::{routing, Router, Server};
use clap::{error::ErrorKind, Args, CommandFactory};
use tower_http::cors::CorsLayer; use tower_http::cors::CorsLayer;
use tracing::info; use tracing::info;
use utoipa::OpenApi; use utoipa::OpenApi;
use utoipa_swagger_ui::SwaggerUi; use utoipa_swagger_ui::SwaggerUi;
use crate::Cli;
#[derive(OpenApi)] #[derive(OpenApi)]
#[openapi( #[openapi(
paths(events::log_event, completions::completion,), paths(events::log_event, completions::completion,),