Skip to content

Commit 6521fd9

Browse files
authored
f (#660)
Signed-off-by: sagudev <[email protected]>
1 parent 16e1e3a commit 6521fd9

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

mozjs/src/realm.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,18 @@ impl<'cx> AutoRealm<'cx> {
9696

9797
/// If we can get &mut AutoRealm then we are current realm,
9898
/// because if there existed other current realm, we couldn't get &mut AutoRealm.
99-
pub fn current_realm(&'cx mut self) -> CurrentRealm<'cx> {
99+
/// ```
100+
/// use mozjs::context::JSContext;
101+
/// use mozjs::jsapi::JSObject;
102+
/// use mozjs::realm::AutoRealm;
103+
/// use std::ptr::NonNull;
104+
///
105+
/// fn f(cx: &mut JSContext, t: NonNull<JSObject>) {
106+
/// let mut realm = AutoRealm::new(cx, t);
107+
/// let mut current_realm = realm.current_realm();
108+
/// }
109+
/// ```
110+
pub fn current_realm(&'_ mut self) -> CurrentRealm<'_> {
100111
CurrentRealm::assert(self)
101112
}
102113

0 commit comments

Comments
 (0)