add BoxExt trait (#2036)

This commit is contained in:
Luna Yao
2026-03-30 07:25:53 +02:00
committed by GitHub
parent 01dd9a05c3
commit 61c741f887
+8
View File
@@ -141,3 +141,11 @@ pub fn weak_upgrade<T>(weak: &std::sync::Weak<T>) -> anyhow::Result<std::sync::A
weak.upgrade()
.ok_or_else(|| anyhow::anyhow!("{} not available", std::any::type_name::<T>()))
}
pub trait BoxExt: Sized {
fn boxed(self) -> Box<Self> {
Box::new(self)
}
}
impl<T> BoxExt for T {}