From 6a66ca0d1e3045fa22bc25c00c8a8cd2f59d3d6e Mon Sep 17 00:00:00 2001 From: KanadeSiina Date: Wed, 17 Jan 2024 07:44:05 +0000 Subject: [PATCH] format code --- judge-core/src/compiler.rs | 4 ++-- judge-core/src/judge/interact.rs | 4 +--- judge-core/tests/judge_test.rs | 12 ++++++++---- judger/src/lib.rs | 2 +- judger/src/server/main.rs | 2 +- judger/src/server/service/state.rs | 6 +++--- 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/judge-core/src/compiler.rs b/judge-core/src/compiler.rs index 4f667bc..c2184bd 100644 --- a/judge-core/src/compiler.rs +++ b/judge-core/src/compiler.rs @@ -1,9 +1,9 @@ use crate::error::JudgeCoreError; use crate::utils::get_pathbuf_str; use anyhow::anyhow; -use serde_derive::{Serialize, Deserialize}; -use std::{fmt, fs}; +use serde_derive::{Deserialize, Serialize}; use std::path::PathBuf; +use std::{fmt, fs}; use std::{process::Command, str::FromStr}; const TEMPLATE_ARG_SRC_PATH: &str = "{src_path}"; diff --git a/judge-core/src/judge/interact.rs b/judge-core/src/judge/interact.rs index 1d0dbd3..f7c28fe 100644 --- a/judge-core/src/judge/interact.rs +++ b/judge-core/src/judge/interact.rs @@ -9,9 +9,7 @@ use crate::utils::get_pathbuf_str; use nix::errno::Errno; use nix::fcntl::{fcntl, FcntlArg, OFlag}; -use nix::sys::epoll::{ - Epoll, EpollCreateFlags, EpollEvent, EpollFlags, -}; +use nix::sys::epoll::{Epoll, EpollCreateFlags, EpollEvent, EpollFlags}; use nix::unistd::{pipe, read, write}; use std::fs::File; use std::os::fd::BorrowedFd; diff --git a/judge-core/tests/judge_test.rs b/judge-core/tests/judge_test.rs index 738d905..e07b07d 100644 --- a/judge-core/tests/judge_test.rs +++ b/judge-core/tests/judge_test.rs @@ -3,10 +3,13 @@ use std::path::PathBuf; use judge_core::{ compiler::Language, judge::{ - interact::run_interact, result::JudgeVerdict, CheckerConfig, JudgeConfig, ProgramConfig, - RuntimeConfig, TestdataConfig, builder::{JudgeBuilder, JudgeBuilderInput}, + builder::{JudgeBuilder, JudgeBuilderInput}, + interact::run_interact, + result::JudgeVerdict, + CheckerConfig, JudgeConfig, ProgramConfig, RuntimeConfig, TestdataConfig, }, - run::{executor::Executor, RlimitConfigs}, package::PackageType, + package::PackageType, + run::{executor::Executor, RlimitConfigs}, }; use judge_core::judge::common::run_judge; @@ -156,7 +159,8 @@ fn test_build_icpc() { package_path: PathBuf::from(TEST_DATA_PATH).join("packages/icpc/hello_world"), runtime_path: PathBuf::from(TEST_TEMP_PATH).join("hello_world"), src_language: Language::Cpp, - src_path: PathBuf::from(TEST_DATA_PATH).join("built-in-programs/src/programs/read_and_write.cpp"), + src_path: PathBuf::from(TEST_DATA_PATH) + .join("built-in-programs/src/programs/read_and_write.cpp"), }) .unwrap(); log::info!("builder: {:?}", builder); diff --git a/judger/src/lib.rs b/judger/src/lib.rs index 6c31b34..0443af3 100644 --- a/judger/src/lib.rs +++ b/judger/src/lib.rs @@ -1,2 +1,2 @@ #[allow(dead_code)] -pub mod service; \ No newline at end of file +pub mod service; diff --git a/judger/src/server/main.rs b/judger/src/server/main.rs index 2614dcd..2efc354 100644 --- a/judger/src/server/main.rs +++ b/judger/src/server/main.rs @@ -6,7 +6,7 @@ mod service; extern crate serde_derive; extern crate lazy_static; -use actix_web::{App, HttpServer, web::Data}; +use actix_web::{web::Data, App, HttpServer}; use utoipa::OpenApi; #[actix_web::main] // or #[tokio::main] diff --git a/judger/src/server/service/state.rs b/judger/src/server/service/state.rs index a37b4b6..87e7d3e 100644 --- a/judger/src/server/service/state.rs +++ b/judger/src/server/service/state.rs @@ -53,7 +53,7 @@ pub async fn get_state() -> Result { let state = STATE.read().map_err(|e| { ServiceError::InternalError(anyhow::anyhow!("Failed to lock state: {:?}", e)) })?; - Ok(HttpResponse::Ok().content_type( - "application/text; charset=utf-8", - ).body(format!("{:?}", *state))) + Ok(HttpResponse::Ok() + .content_type("application/text; charset=utf-8") + .body(format!("{:?}", *state))) }