Struct script::test::DomRefCell
source · pub struct DomRefCell<T> {
value: RefCell<T>,
}
Expand description
A mutable field in the DOM.
This extends the API of std::cell::RefCell
to allow unsafe access in
certain situations, with dynamic checking in debug builds.
Fields§
§value: RefCell<T>
Implementations§
source§impl<T> DomRefCell<T>
impl<T> DomRefCell<T>
sourcepub unsafe fn borrow_for_layout(&self) -> &T
pub unsafe fn borrow_for_layout(&self) -> &T
Return a reference to the contents.
For use in the layout thread only.
sourcepub unsafe fn borrow_for_script_deallocation(&self) -> &mut T
pub unsafe fn borrow_for_script_deallocation(&self) -> &mut T
Borrow the contents for the purpose of script deallocation.
sourcepub unsafe fn borrow_mut_for_layout(&self) -> &mut T
pub unsafe fn borrow_mut_for_layout(&self) -> &mut T
Mutably borrow a cell for layout. Ideally this would use
RefCell::try_borrow_mut_unguarded
but that doesn’t exist yet.
source§impl<T> DomRefCell<T>
impl<T> DomRefCell<T>
sourcepub fn new(value: T) -> DomRefCell<T>
pub fn new(value: T) -> DomRefCell<T>
Create a new DomRefCell
containing value
.
sourcepub fn borrow(&self) -> Ref<'_, T>
pub fn borrow(&self) -> Ref<'_, T>
Immutably borrows the wrapped value.
The borrow lasts until the returned Ref
exits scope. Multiple
immutable borrows can be taken out at the same time.
Panics
Panics if this is called off the script thread.
Panics if the value is currently mutably borrowed.
sourcepub fn borrow_mut(&self) -> RefMut<'_, T>
pub fn borrow_mut(&self) -> RefMut<'_, T>
Mutably borrows the wrapped value.
The borrow lasts until the returned RefMut
exits scope. The value
cannot be borrowed while this borrow is active.
Panics
Panics if this is called off the script thread.
Panics if the value is currently borrowed.
sourcepub fn try_borrow(&self) -> Result<Ref<'_, T>, BorrowError>
pub fn try_borrow(&self) -> Result<Ref<'_, T>, BorrowError>
Attempts to immutably borrow the wrapped value.
The borrow lasts until the returned Ref
exits scope. Multiple
immutable borrows can be taken out at the same time.
Returns None
if the value is currently mutably borrowed.
Panics
Panics if this is called off the script thread.
sourcepub fn try_borrow_mut(&self) -> Result<RefMut<'_, T>, BorrowMutError>
pub fn try_borrow_mut(&self) -> Result<RefMut<'_, T>, BorrowMutError>
Mutably borrows the wrapped value.
The borrow lasts until the returned RefMut
exits scope. The value
cannot be borrowed while this borrow is active.
Returns None
if the value is currently borrowed.
Panics
Panics if this is called off the script thread.
Trait Implementations§
source§impl<T: Clone> Clone for DomRefCell<T>
impl<T: Clone> Clone for DomRefCell<T>
source§fn clone(&self) -> DomRefCell<T>
fn clone(&self) -> DomRefCell<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<T: CustomTraceable> CustomTraceable for DomRefCell<T>
impl<T: CustomTraceable> CustomTraceable for DomRefCell<T>
source§impl<T: Debug> Debug for DomRefCell<T>
impl<T: Debug> Debug for DomRefCell<T>
source§impl<T: Default> Default for DomRefCell<T>
impl<T: Default> Default for DomRefCell<T>
source§fn default() -> DomRefCell<T>
fn default() -> DomRefCell<T>
source§impl<T> MallocSizeOf for DomRefCell<T>where
T: MallocSizeOf,
impl<T> MallocSizeOf for DomRefCell<T>where T: MallocSizeOf,
source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
source§impl<K, V> Maplike for DomRefCell<IndexMap<K, V>>where
K: ToJSValConvertible + Eq + PartialEq + Hash + Clone,
V: ToJSValConvertible + Clone,
impl<K, V> Maplike for DomRefCell<IndexMap<K, V>>where K: ToJSValConvertible + Eq + PartialEq + Hash + Clone, V: ToJSValConvertible + Clone,
fn get_index(&self, index: u32) -> Option<(Self::Key, Self::Value)>
fn get(&self, key: Self::Key) -> Option<Self::Value>
fn size(&self) -> u32
fn set(&self, key: Self::Key, value: Self::Value)
fn has(&self, key: Self::Key) -> bool
fn clear(&self)
fn delete(&self, key: Self::Key) -> bool
source§impl<T: PartialEq> PartialEq<DomRefCell<T>> for DomRefCell<T>
impl<T: PartialEq> PartialEq<DomRefCell<T>> for DomRefCell<T>
source§fn eq(&self, other: &DomRefCell<T>) -> bool
fn eq(&self, other: &DomRefCell<T>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<K> Setlike for DomRefCell<IndexSet<K>>where
K: ToJSValConvertible + Eq + PartialEq + Hash + Clone,
impl<K> Setlike for DomRefCell<IndexSet<K>>where K: ToJSValConvertible + Eq + PartialEq + Hash + Clone,
source§impl<T: JSTraceable> Traceable for DomRefCell<T>
impl<T: JSTraceable> Traceable for DomRefCell<T>
impl<T> StructuralPartialEq for DomRefCell<T>
Auto Trait Implementations§
impl<T> !RefUnwindSafe for DomRefCell<T>
impl<T> Send for DomRefCell<T>where T: Send,
impl<T> !Sync for DomRefCell<T>
impl<T> Unpin for DomRefCell<T>where T: Unpin,
impl<T> UnwindSafe for DomRefCell<T>where T: UnwindSafe,
Blanket Implementations§
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> MaybeBoxed<Box<T, Global>> for T
impl<T> MaybeBoxed<Box<T, Global>> for T
source§fn maybe_boxed(self) -> Box<T, Global>
fn maybe_boxed(self) -> Box<T, Global>
source§impl<T> MaybeBoxed<T> for T
impl<T> MaybeBoxed<T> for T
source§fn maybe_boxed(self) -> T
fn maybe_boxed(self) -> T
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<R, P> ReadPrimitive<R> for Pwhere
R: Read + ReadEndian<P>,
P: Default,
impl<R, P> ReadPrimitive<R> for Pwhere R: Read + ReadEndian<P>, P: Default,
source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.