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 layout only.
§Safety
Unlike RefCell::borrow, this method is unsafe because it does not return a Ref, thus leaving the borrow flag untouched. Mutably borrowing the RefCell while the reference returned by this method is alive is undefined behaviour.
§Panics
Panics if this is called from anywhere other than the layout thread
Panics if the value is currently mutably borrowed.
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.
§Safety
Unlike RefCell::borrow, this method is unsafe because it does not return a Ref, thus leaving the borrow flag untouched. Mutably borrowing the RefCell while the reference returned by this method is alive is undefined behaviour.
§Panics
Panics if this is called from anywhere other than the script thread.
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.
§Safety
Unlike RefCell::borrow, this method is unsafe because it does not return a Ref, thus leaving the borrow flag untouched. Mutably borrowing the RefCell while the reference returned by this method is alive is undefined behaviour.
§Panics
Panics if this is called from anywhere other than the layout thread.
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 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 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>>
impl<K, V> Maplike for DomRefCell<IndexMap<K, V>>
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 for DomRefCell<T>
impl<T: PartialEq> PartialEq 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>>
impl<K> Setlike for DomRefCell<IndexSet<K>>
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> !Freeze for DomRefCell<T>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Filterable for T
impl<T> Filterable for T
source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
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> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> MaybeBoxed<Box<T>> for T
impl<T> MaybeBoxed<Box<T>> for T
source§fn maybe_boxed(self) -> Box<T>
fn maybe_boxed(self) -> Box<T>
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 P
impl<R, P> ReadPrimitive<R> for P
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()
.