aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/js.rs
diff options
context:
space:
mode:
authorMs2ger <ms2ger@gmail.com>2015-01-01 12:20:43 +0100
committerMs2ger <ms2ger@gmail.com>2015-01-01 20:36:43 +0100
commitc9f26dfd599bd50deac9e120bd54c9dbdfe40ae0 (patch)
treed275ef196a7d623d950f21a39ce8a7c989a996f9 /components/script/dom/bindings/js.rs
parent1290c1879415c80b374bc3ff6378aec899850048 (diff)
downloadservo-c9f26dfd599bd50deac9e120bd54c9dbdfe40ae0.tar.gz
servo-c9f26dfd599bd50deac9e120bd54c9dbdfe40ae0.zip
Rename Root::root_ref() to Root::r().
As it will be used much more widely after the upcoming changes, this limits the effort reading and writing the method calls.
Diffstat (limited to 'components/script/dom/bindings/js.rs')
-rw-r--r--components/script/dom/bindings/js.rs24
1 files changed, 12 insertions, 12 deletions
diff --git a/components/script/dom/bindings/js.rs b/components/script/dom/bindings/js.rs
index 42ba52b6d34..3eb911e7be3 100644
--- a/components/script/dom/bindings/js.rs
+++ b/components/script/dom/bindings/js.rs
@@ -31,11 +31,11 @@
//! Both `Temporary<T>` and `JS<T>` do not allow access to their inner value without explicitly
//! creating a stack-based root via the `root` method. This returns a `Root<T>`, which causes
//! the JS-owned value to be uncollectable for the duration of the `Root` object's lifetime.
-//! A `JSRef<T>` can be obtained from a `Root<T>` either by dereferencing the `Root<T>` (`*rooted`)
-//! or explicitly calling the `root_ref` method. These `JSRef<T>` values are not allowed to
-//! outlive their originating `Root<T>`, to ensure that all interactions with the enclosed value
-//! only occur when said value is uncollectable, and will cause static lifetime errors if
-//! misused.
+//! A `JSRef<T>` can be obtained from a `Root<T>` by calling the `r` method. (Dereferencing the
+//! object is still supported, but as it is unsafe, this is deprecated.) These `JSRef<T>` values
+//! are not allowed to outlive their originating `Root<T>`, to ensure that all interactions with
+//! the enclosed value only occur when said value is uncollectable, and will cause static lifetime
+//! errors if misused.
//!
//! Other miscellaneous helper traits:
//!
@@ -307,23 +307,23 @@ impl<From, To> JS<From> {
/// Get an `Option<JSRef<T>>` out of an `Option<Root<T>>`
pub trait RootedReference<T> {
- fn root_ref<'a>(&'a self) -> Option<JSRef<'a, T>>;
+ fn r<'a>(&'a self) -> Option<JSRef<'a, T>>;
}
impl<T: Reflectable> RootedReference<T> for Option<Root<T>> {
- fn root_ref<'a>(&'a self) -> Option<JSRef<'a, T>> {
- self.as_ref().map(|root| root.root_ref())
+ fn r<'a>(&'a self) -> Option<JSRef<'a, T>> {
+ self.as_ref().map(|root| root.r())
}
}
/// Get an `Option<Option<JSRef<T>>>` out of an `Option<Option<Root<T>>>`
pub trait OptionalRootedReference<T> {
- fn root_ref<'a>(&'a self) -> Option<Option<JSRef<'a, T>>>;
+ fn r<'a>(&'a self) -> Option<Option<JSRef<'a, T>>>;
}
impl<T: Reflectable> OptionalRootedReference<T> for Option<Option<Root<T>>> {
- fn root_ref<'a>(&'a self) -> Option<Option<JSRef<'a, T>>> {
- self.as_ref().map(|inner| inner.root_ref())
+ fn r<'a>(&'a self) -> Option<Option<JSRef<'a, T>>> {
+ self.as_ref().map(|inner| inner.r())
}
}
@@ -513,7 +513,7 @@ impl<T: Reflectable> Root<T> {
/// Obtain a safe reference to the wrapped JS owned-value that cannot outlive
/// the lifetime of this root.
- pub fn root_ref<'b>(&'b self) -> JSRef<'b,T> {
+ pub fn r<'b>(&'b self) -> JSRef<'b, T> {
self.jsref.clone()
}
}