From bafccaf6a55efab945b107cb4fe4f4b97d3df259 Mon Sep 17 00:00:00 2001 From: Jisu-Woniu <31986081+Jisu-Woniu@users.noreply.github.com> Date: Sun, 11 Feb 2024 18:03:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=9A=A8=20fix=20clippy=20lint=20war?= =?UTF-8?q?ning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/testing.yml | 4 ++-- src/user.rs | 24 ++++++++---------------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index f76e953..e568783 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -26,8 +26,8 @@ jobs: run: | sudo apt update && sudo apt upgrade -y && \ sudo apt install -y protobuf-compiler libprotobuf-dev - - name: Build - run: cargo build --verbose + - name: Run clippy lint + run: cargo clippy --all-targets --all-features - name: Run tests run: cargo test --verbose - name: Build Debian package diff --git a/src/user.rs b/src/user.rs index 0241d43..5b4579e 100644 --- a/src/user.rs +++ b/src/user.rs @@ -2,33 +2,25 @@ use std::sync::OnceLock; use uzers::{get_group_by_name, get_user_by_name}; -const BUILDER_UID_LOCK: OnceLock> = OnceLock::new(); -const BUILDER_GID_LOCK: OnceLock> = OnceLock::new(); -const RUNNER_UID_LOCK: OnceLock> = OnceLock::new(); -const RUNNER_GID_LOCK: OnceLock> = OnceLock::new(); +static BUILDER_UID_LOCK: OnceLock> = OnceLock::new(); +static BUILDER_GID_LOCK: OnceLock> = OnceLock::new(); +static RUNNER_UID_LOCK: OnceLock> = OnceLock::new(); +static RUNNER_GID_LOCK: OnceLock> = OnceLock::new(); pub fn builder_uid() -> Option { - BUILDER_UID_LOCK - .get_or_init(|| get_user_by_name("rsjudge-builder").map(|u| u.uid())) - .clone() + *BUILDER_UID_LOCK.get_or_init(|| get_user_by_name("rsjudge-builder").map(|u| u.uid())) } pub fn builder_gid() -> Option { - BUILDER_GID_LOCK - .get_or_init(|| get_group_by_name("rsjudge-builder").map(|g| g.gid())) - .clone() + *BUILDER_GID_LOCK.get_or_init(|| get_group_by_name("rsjudge-builder").map(|g| g.gid())) } pub fn runner_uid() -> Option { - RUNNER_UID_LOCK - .get_or_init(|| get_user_by_name("rsjudge-runner").map(|u| u.uid())) - .clone() + *RUNNER_UID_LOCK.get_or_init(|| get_user_by_name("rsjudge-runner").map(|u| u.uid())) } pub fn runner_gid() -> Option { - RUNNER_GID_LOCK - .get_or_init(|| get_group_by_name("rsjudge-runner").map(|g| g.gid())) - .clone() + *RUNNER_GID_LOCK.get_or_init(|| get_group_by_name("rsjudge-runner").map(|g| g.gid())) } #[cfg(all(test, unix))]