Skip to content

Commit

Permalink
fix: use reference to T in ::new
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerixyz committed Feb 2, 2022
1 parent 4d1dd4b commit 1dd8958
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion crates/libs/windows/src/core/agile_reference.rs
Expand Up @@ -9,7 +9,10 @@ pub struct AgileReference<T>(IAgileReference, PhantomData<T>);

impl<T: Interface> AgileReference<T> {
/// Creates an agile reference to the object.
pub fn new<'a, O: IntoParam<'a, IUnknown>>(object: O) -> Result<Self> {
pub fn new<'a>(object: &'a T) -> Result<Self>
where
&'a T: IntoParam<'a, IUnknown>,
{
unsafe { RoGetAgileReference(AGILEREFERENCE_DEFAULT, &T::IID, object).map(|reference| Self(reference, Default::default())) }
}

Expand Down
2 changes: 1 addition & 1 deletion crates/tests/agile_reference/tests/tests.rs
Expand Up @@ -4,7 +4,7 @@ use windows::Media::Control::GlobalSystemMediaTransportControlsSessionManager;
#[test]
fn test() -> Result<()> {
let manager = GlobalSystemMediaTransportControlsSessionManager::RequestAsync()?.get()?;
let reference = AgileReference::<GlobalSystemMediaTransportControlsSessionManager>::new(&manager)?;
let reference = AgileReference::new(&manager)?;

let handle = std::thread::spawn(move || {
let manager = reference.resolve()?;
Expand Down

0 comments on commit 1dd8958

Please sign in to comment.