refactor: directly wrap structs

This commit is contained in:
2025-03-12 18:28:30 -04:00
parent 44f7b9a00f
commit 85729401e5
8 changed files with 50 additions and 80 deletions

View File

@@ -14,25 +14,19 @@ use azalea::{Client as AzaleaClient, world::MinecraftEntityId};
use mlua::{Lua, Result, UserData, UserDataFields, UserDataMethods};
use std::ops::{Deref, DerefMut};
pub struct Client {
pub inner: Option<AzaleaClient>,
}
pub struct Client(pub Option<AzaleaClient>);
impl Deref for Client {
type Target = AzaleaClient;
fn deref(&self) -> &Self::Target {
self.inner
.as_ref()
.expect("should have received init event")
self.0.as_ref().expect("should have received init event")
}
}
impl DerefMut for Client {
fn deref_mut(&mut self) -> &mut Self::Target {
self.inner
.as_mut()
.expect("should have received init event")
self.0.as_mut().expect("should have received init event")
}
}