move hostname function to utils

This commit is contained in:
Luna Yao committed 2026-04-20 00:51:59 +02:00
1 parent 11626d8082
commit 524c8d9987
3 files changed
+11 -14

No files matched your search

+7
View File
@@ -23,6 +23,13 @@ pub fn weak_upgrade<T>(weak: &Weak<T>) -> anyhow::Result<Arc<T>> {
.ok_or_else(|| anyhow::anyhow!("{} not available", std::any::type_name::<T>()))
}
pub fn hostname() -> String {
hostname::get()
.unwrap_or_else(|_| "localhost".into())
.to_string_lossy()
.into_owned()
}
pub trait BoxExt: Sized {
fn boxed(self) -> Box<Self> {
Box::new(self)