refactor: rust nightly format (#197)

* chore: turn on group format

* turn on nightly fmt
This commit is contained in:
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
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
components: rustfmt, clippy
toolchain: nightly
components: rustfmt
- name: Cargo fmt
run: cargo fmt --check
run: cargo +nightly fmt --check
release-binary:
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 rust_cxx_cmake_bridge::read_cmake_generated;
use std::env;
use std::path::PathBuf;
fn main() {
// Tell cargo to invalidate the built crate whenever the wrapper changes

View File

@ -1,5 +1,4 @@
use std::io::Write;
use std::path::PathBuf;
use std::{io::Write, path::PathBuf};
// ## lib_name: "protobufd"
// ## 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 lazy_static::lazy_static;
use serde::Serialize;
use std::fs;
use std::io::{BufWriter, Write};
use std::sync::Mutex;
lazy_static! {
static ref WRITER: Mutex<BufWriter<fs::File>> = {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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