v0.1.3-rc.4.2

This commit is contained in:
wisdgod
2025-01-28 15:00:27 +08:00
parent cb244d7282
commit 22121f3beb
6 changed files with 51 additions and 23 deletions

View File

@@ -48,6 +48,24 @@ pub fn parse_usize_from_env(key: &str, default: usize) -> usize {
.unwrap_or(default)
}
pub trait TrimNewlines {
fn trim_leading_newlines(self) -> Self;
}
impl TrimNewlines for String {
#[inline(always)]
fn trim_leading_newlines(mut self) -> Self {
if self.as_bytes().get(..2) == Some(b"\n\n".as_slice()) {
unsafe {
let vec = self.as_mut_vec();
vec.copy_within(2.., 0);
vec.truncate(vec.len() - 2);
}
}
self
}
}
pub async fn get_token_profile(auth_token: &str) -> Option<TokenProfile> {
let user_id = extract_user_id(auth_token)?;