-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(rsjudge-runner): 🙈 hide internal macros from other crates
- Loading branch information
1 parent
564bebe
commit 61b7bbc
Showing
3 changed files
with
27 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/// 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<Option<User>> = OnceLock::new(); | ||
INNER | ||
.get_or_init(|| get_user_by_name($name)) | ||
.as_ref() | ||
.ok_or_else(|| Error::UserNotFound { username: $name }) | ||
} | ||
)* | ||
}; | ||
} |