Add rust lint CI job.
Some checks failed
Check / Check Rust (pull_request) Failing after 21s

This commit is contained in:
Drew 2025-12-13 23:16:33 -08:00
parent 311755c812
commit a8d97ce0b3
30 changed files with 182 additions and 108 deletions

View file

@ -50,7 +50,7 @@ impl<T> DerefMut for MutexGuard<'_, T> {
}
}
impl<T> Mutex<T> {
impl<'a, T> Mutex<T> {
pub fn new(data: T) -> Mutex<T> {
Mutex {
cap: syscall::mutex_create().unwrap(),
@ -58,7 +58,7 @@ impl<T> Mutex<T> {
}
}
pub fn lock(&self) -> MutexGuard<T> {
pub fn lock(&'a self) -> MutexGuard<'a, T> {
syscall::mutex_lock(&self.cap).unwrap();
MutexGuard { mutex: self }
@ -70,3 +70,12 @@ impl<T> Drop for MutexGuard<'_, T> {
syscall::mutex_release(&self.mutex.cap).unwrap();
}
}
impl<T> Default for Mutex<T>
where
T: Default,
{
fn default() -> Self {
Self::new(T::default())
}
}