mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Add an extended_deref method to JSRef
The extended_deref method will take a JSRef<'a, T> and produce an &'a T, in contrast to the standard deref method that takes an &'b JSRef<'a, T> and produces an &'a T. This is useful when avoiding passing a JSRef by reference.
This commit is contained in:
parent
1e5770a138
commit
8334942d0c
1 changed files with 8 additions and 0 deletions
|
@ -493,6 +493,14 @@ impl<'a,T> JSRef<'a,T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, T: Reflectable> JSRef<'a, T> {
|
||||
pub fn extended_deref(self) -> &'a T {
|
||||
unsafe {
|
||||
&*self.ptr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T: Reflectable> Reflectable for JSRef<'a, T> {
|
||||
fn reflector<'a>(&'a self) -> &'a Reflector {
|
||||
self.deref().reflector()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue