Replace Root::deref by a custom get_unsound_ref_forever method.

This will hopefully make it clearer that this is not the correct function
to call.
This commit is contained in:
Ms2ger 2015-02-05 16:28:02 +01:00
parent 40c59724b2
commit d8c2c88bbd
8 changed files with 70 additions and 61 deletions

View file

@ -614,6 +614,17 @@ impl<T: Reflectable> Root<T> {
chain: ContravariantLifetime,
}
}
/// Obtain an unsafe reference to the wrapped JS owned-value that can
/// outlive the lifetime of this root.
///
/// DO NOT CALL.
pub fn get_unsound_ref_forever<'b>(&self) -> JSRef<'b, T> {
JSRef {
ptr: self.jsref.ptr,
chain: ContravariantLifetime,
}
}
}
#[unsafe_destructor]
@ -623,13 +634,6 @@ impl<T: Reflectable> Drop for Root<T> {
}
}
impl<'b, T: Reflectable> Deref for Root<T> {
type Target = JSRef<'b, T>;
fn deref<'c>(&'c self) -> &'c JSRef<'b, T> {
&self.jsref
}
}
impl<'a, T: Reflectable> Deref for JSRef<'a, T> {
type Target = T;
fn deref<'b>(&'b self) -> &'b T {