diff --git a/crates/libs/core/src/ref.rs b/crates/libs/core/src/ref.rs index 3c8db6f0ab..c96a4c47cc 100644 --- a/crates/libs/core/src/ref.rs +++ b/crates/libs/core/src/ref.rs @@ -4,14 +4,9 @@ use super::*; #[repr(transparent)] pub struct Ref<'a, T: Type>(T::Abi, std::marker::PhantomData<&'a T>); -impl<'a, T: Type> Ref<'a, T> { - /// Reads the borrowed value. - pub fn read(&self) -> &T::Default { +impl<'a, T: Type> std::ops::Deref for Ref<'a, T> { + type Target = T::Default; + fn deref(&self) -> &Self::Target { unsafe { std::mem::transmute(&self.0) } } - - /// Clones the borrowed value. - pub fn ok(&self) -> Result { - T::from_default(self.read()) - } } diff --git a/crates/tests/interface_core/tests/ref.rs b/crates/tests/interface_core/tests/ref.rs index e5742fc366..4527a81729 100644 --- a/crates/tests/interface_core/tests/ref.rs +++ b/crates/tests/interface_core/tests/ref.rs @@ -31,13 +31,13 @@ impl ITest_Impl for Test { output.write(input).into() } unsafe fn hstring(&self, input: Ref, output: RefMut) -> HRESULT { - output.write(input.read().clone()).into() + output.write(input.clone()).into() } unsafe fn interface(&self, input: Ref, output: RefMut) -> HRESULT { - output.write(input.read().clone()).into() + output.write(input.clone()).into() } unsafe fn required_input(&self, input: Ref, output: RefMut) -> HRESULT { - if input.read().is_none() { + if input.is_none() { E_INVALIDARG } else { self.interface(input, output) @@ -56,13 +56,13 @@ impl ITest_Impl for Test { output.write(input) } unsafe fn result_hstring(&self, input: Ref, output: RefMut) -> Result<()> { - output.write(input.read().clone()) + output.write(input.clone()) } unsafe fn result_interface(&self, input: Ref, output: RefMut) -> Result<()> { - output.write(input.read().clone()) + output.write(input.clone()) } unsafe fn result_required_input(&self, input: Ref, output: RefMut) -> Result<()> { - if input.read().is_none() { + if input.is_none() { E_INVALIDARG.ok() } else { self.result_interface(input, output)