From 61b7bbc6a78e8f02d15236fc2e9e2c1de6a05cb2 Mon Sep 17 00:00:00 2001
From: Jisu-Woniu <31986081+Jisu-Woniu@users.noreply.github.com>
Date: Thu, 4 Apr 2024 02:24:21 +0800
Subject: [PATCH] =?UTF-8?q?fix(rsjudge-runner):=20=F0=9F=99=88=20hide=20in?=
=?UTF-8?q?ternal=20macros=20from=20other=20crates?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
crates/rsjudge-runner/src/lib.rs | 4 ++++
crates/rsjudge-runner/src/user.rs | 25 +++++--------------------
crates/rsjudge-runner/src/user_macro.rs | 18 ++++++++++++++++++
3 files changed, 27 insertions(+), 20 deletions(-)
create mode 100644 crates/rsjudge-runner/src/user_macro.rs
diff --git a/crates/rsjudge-runner/src/lib.rs b/crates/rsjudge-runner/src/lib.rs
index 3bc02d3..8bc4f8f 100644
--- a/crates/rsjudge-runner/src/lib.rs
+++ b/crates/rsjudge-runner/src/lib.rs
@@ -13,7 +13,11 @@ pub use crate::{
mod caps_check;
mod error;
+
+#[macro_use]
+mod user_macro;
pub mod user;
+
pub trait RunAs {
type Error;
fn run_as(&mut self, user: &User) -> Result<&mut Self>;
diff --git a/crates/rsjudge-runner/src/user.rs b/crates/rsjudge-runner/src/user.rs
index 1c3c9de..da2899e 100644
--- a/crates/rsjudge-runner/src/user.rs
+++ b/crates/rsjudge-runner/src/user.rs
@@ -6,26 +6,11 @@ use std::sync::OnceLock;
use uzers::{get_user_by_name, User};
-use crate::error::{Error, Result};
-
-/// Generate functions to get user instances.
-macro_rules! users {
- ($($vis:vis fn $id:ident() => $name:literal);* $(;)?) => {
- $(
- #[doc = concat!("Get an instance of user `", $name, "`.")]
- ///
- /// # Errors
- /// Returns an error if the user is not found.
- pub fn $id() -> Result<&'static User> {
- static INNER: OnceLock