File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change 33 * You can obtain one at http://mozilla.org/MPL/2.0/. */
44
55use std:: marker:: PhantomData ;
6- use std:: ops:: Deref ;
6+ use std:: ops:: { Deref , DerefMut } ;
77use std:: ptr:: NonNull ;
88
99pub use crate :: jsapi:: JSContext as RawJSContext ;
@@ -170,8 +170,20 @@ impl Deref for JSContext {
170170 /// This exists to make migration to [JSContext] easier,
171171 /// but it will be eventually removed as it is **unsafe**.
172172 ///
173- /// Use [JSContext::raw_cx ] instead.
173+ /// Use [JSContext::raw_cx_no_gc ] instead.
174174 fn deref ( & ' _ self ) -> & ' _ Self :: Target {
175175 unsafe { std:: mem:: transmute :: < & NonNull < RawJSContext > , & * mut RawJSContext > ( & self . ptr ) }
176176 }
177177}
178+
179+ impl DerefMut for JSContext {
180+ /// This exists to make migration to [JSContext] easier,
181+ /// but it will be eventually removed as it is **unsafe**.
182+ ///
183+ /// Use [JSContext::raw_cx] instead.
184+ fn deref_mut ( & ' _ mut self ) -> & ' _ mut Self :: Target {
185+ unsafe {
186+ std:: mem:: transmute :: < & mut NonNull < RawJSContext > , & mut * mut RawJSContext > ( & mut self . ptr )
187+ }
188+ }
189+ }
Original file line number Diff line number Diff line change @@ -307,7 +307,7 @@ pub struct Runtime {
307307impl Runtime {
308308 /// Get the `JSContext` for this thread.
309309 ///
310- /// This will eventually be removed for in favour of [JSContext]
310+ /// This will eventually be removed for in favour of [crate::context:: JSContext]
311311 pub fn get ( ) -> Option < NonNull < JSContext > > {
312312 CONTEXT . with ( |context| context. get ( ) )
313313 }
You can’t perform that action at this time.
0 commit comments