pub struct RwLock<R, T>where
T: ?Sized,{ /* private fields */ }Expand description
A reader-writer lock
This type of lock allows a number of readers or at most one writer at any point in time. The write portion of this lock typically allows modification of the underlying data (exclusive access) and the read portion of this lock typically allows for read-only access (shared access).
The type parameter T represents the data that this lock protects. It is
required that T satisfies Send to be shared across threads and Sync to
allow concurrent access through readers. The RAII guards returned from the
locking methods implement Deref (and DerefMut for the write methods)
to allow access to the contained of the lock.
Implementations§
Source§impl<R, T> RwLock<R, T>where
R: RawRwLock,
impl<R, T> RwLock<R, T>where
R: RawRwLock,
Sourcepub const fn new(val: T) -> RwLock<R, T>
pub const fn new(val: T) -> RwLock<R, T>
Creates a new instance of an RwLock<T> which is unlocked.
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consumes this RwLock, returning the underlying data.
Source§impl<R, T> RwLock<R, T>
impl<R, T> RwLock<R, T>
Source§impl<R, T> RwLock<R, T>
impl<R, T> RwLock<R, T>
Sourcepub unsafe fn make_read_guard_unchecked(&self) -> RwLockReadGuard<'_, R, T>
pub unsafe fn make_read_guard_unchecked(&self) -> RwLockReadGuard<'_, R, T>
Creates a new RwLockReadGuard without checking if the lock is held.
§Safety
This method must only be called if the thread logically holds a read lock.
This function does not increment the read count of the lock. Calling this function when a
guard has already been produced is undefined behaviour unless the guard was forgotten
with mem::forget.
Sourcepub unsafe fn make_write_guard_unchecked(&self) -> RwLockWriteGuard<'_, R, T>
pub unsafe fn make_write_guard_unchecked(&self) -> RwLockWriteGuard<'_, R, T>
Creates a new RwLockReadGuard without checking if the lock is held.
§Safety
This method must only be called if the thread logically holds a write lock.
Calling this function when a guard has already been produced is undefined behaviour unless
the guard was forgotten with mem::forget.
Sourcepub fn read(&self) -> RwLockReadGuard<'_, R, T>
pub fn read(&self) -> RwLockReadGuard<'_, R, T>
Locks this RwLock with shared read access, blocking the current thread
until it can be acquired.
The calling thread will be blocked until there are no more writers which hold the lock. There may be other readers currently inside the lock when this method returns.
Note that attempts to recursively acquire a read lock on a RwLock when
the current thread already holds one may result in a deadlock.
Returns an RAII guard which will release this thread’s shared access once it is dropped.
Sourcepub fn try_read(&self) -> Option<RwLockReadGuard<'_, R, T>>
pub fn try_read(&self) -> Option<RwLockReadGuard<'_, R, T>>
Attempts to acquire this RwLock with shared read access.
If the access could not be granted at this time, then None is returned.
Otherwise, an RAII guard is returned which will release the shared access
when it is dropped.
This function does not block.
Sourcepub fn write(&self) -> RwLockWriteGuard<'_, R, T>
pub fn write(&self) -> RwLockWriteGuard<'_, R, T>
Locks this RwLock with exclusive write access, blocking the current
thread until it can be acquired.
This function will not return while other writers or other readers currently have access to the lock.
Returns an RAII guard which will drop the write access of this RwLock
when dropped.
Sourcepub fn try_write(&self) -> Option<RwLockWriteGuard<'_, R, T>>
pub fn try_write(&self) -> Option<RwLockWriteGuard<'_, R, T>>
Attempts to lock this RwLock with exclusive write access.
If the lock could not be acquired at this time, then None is returned.
Otherwise, an RAII guard is returned which will release the lock when
it is dropped.
This function does not block.
Sourcepub fn get_mut(&mut self) -> &mut T
pub fn get_mut(&mut self) -> &mut T
Returns a mutable reference to the underlying data.
Since this call borrows the RwLock mutably, no actual locking needs to
take place—the mutable borrow statically guarantees no locks exist.
Sourcepub fn is_locked_exclusive(&self) -> bool
pub fn is_locked_exclusive(&self) -> bool
Check if this RwLock is currently exclusively locked.
Sourcepub unsafe fn force_unlock_read(&self)
pub unsafe fn force_unlock_read(&self)
Forcibly unlocks a read lock.
This is useful when combined with mem::forget to hold a lock without
the need to maintain a RwLockReadGuard object alive, for example when
dealing with FFI.
§Safety
This method must only be called if the current thread logically owns a
RwLockReadGuard but that guard has be discarded using mem::forget.
Behavior is undefined if a rwlock is read-unlocked when not read-locked.
Sourcepub unsafe fn force_unlock_write(&self)
pub unsafe fn force_unlock_write(&self)
Forcibly unlocks a write lock.
This is useful when combined with mem::forget to hold a lock without
the need to maintain a RwLockWriteGuard object alive, for example when
dealing with FFI.
§Safety
This method must only be called if the current thread logically owns a
RwLockWriteGuard but that guard has be discarded using mem::forget.
Behavior is undefined if a rwlock is write-unlocked when not write-locked.
Sourcepub unsafe fn raw(&self) -> &R
pub unsafe fn raw(&self) -> &R
Returns the underlying raw reader-writer lock object.
Note that you will most likely need to import the RawRwLock trait from
lock_api to be able to call functions on the raw
reader-writer lock.
§Safety
This method is unsafe because it allows unlocking a mutex while still holding a reference to a lock guard.
Sourcepub fn data_ptr(&self) -> *mut T
pub fn data_ptr(&self) -> *mut T
Returns a raw pointer to the underlying data.
This is useful when combined with mem::forget to hold a lock without
the need to maintain a RwLockReadGuard or RwLockWriteGuard object
alive, for example when dealing with FFI.
§Safety
You must ensure that there are no data races when dereferencing the
returned pointer, for example if the current thread logically owns a
RwLockReadGuard or RwLockWriteGuard but that guard has been discarded
using mem::forget.
Source§impl<R, T> RwLock<R, T>where
R: RawRwLockFair,
T: ?Sized,
impl<R, T> RwLock<R, T>where
R: RawRwLockFair,
T: ?Sized,
Sourcepub unsafe fn force_unlock_read_fair(&self)
pub unsafe fn force_unlock_read_fair(&self)
Forcibly unlocks a read lock using a fair unlock protocol.
This is useful when combined with mem::forget to hold a lock without
the need to maintain a RwLockReadGuard object alive, for example when
dealing with FFI.
§Safety
This method must only be called if the current thread logically owns a
RwLockReadGuard but that guard has be discarded using mem::forget.
Behavior is undefined if a rwlock is read-unlocked when not read-locked.
Sourcepub unsafe fn force_unlock_write_fair(&self)
pub unsafe fn force_unlock_write_fair(&self)
Forcibly unlocks a write lock using a fair unlock protocol.
This is useful when combined with mem::forget to hold a lock without
the need to maintain a RwLockWriteGuard object alive, for example when
dealing with FFI.
§Safety
This method must only be called if the current thread logically owns a
RwLockWriteGuard but that guard has be discarded using mem::forget.
Behavior is undefined if a rwlock is write-unlocked when not write-locked.
Source§impl<R, T> RwLock<R, T>where
R: RawRwLockTimed,
T: ?Sized,
impl<R, T> RwLock<R, T>where
R: RawRwLockTimed,
T: ?Sized,
Sourcepub fn try_read_for(
&self,
timeout: <R as RawRwLockTimed>::Duration,
) -> Option<RwLockReadGuard<'_, R, T>>
pub fn try_read_for( &self, timeout: <R as RawRwLockTimed>::Duration, ) -> Option<RwLockReadGuard<'_, R, T>>
Attempts to acquire this RwLock with shared read access until a timeout
is reached.
If the access could not be granted before the timeout expires, then
None is returned. Otherwise, an RAII guard is returned which will
release the shared access when it is dropped.
Sourcepub fn try_read_until(
&self,
timeout: <R as RawRwLockTimed>::Instant,
) -> Option<RwLockReadGuard<'_, R, T>>
pub fn try_read_until( &self, timeout: <R as RawRwLockTimed>::Instant, ) -> Option<RwLockReadGuard<'_, R, T>>
Attempts to acquire this RwLock with shared read access until a timeout
is reached.
If the access could not be granted before the timeout expires, then
None is returned. Otherwise, an RAII guard is returned which will
release the shared access when it is dropped.
Sourcepub fn try_write_for(
&self,
timeout: <R as RawRwLockTimed>::Duration,
) -> Option<RwLockWriteGuard<'_, R, T>>
pub fn try_write_for( &self, timeout: <R as RawRwLockTimed>::Duration, ) -> Option<RwLockWriteGuard<'_, R, T>>
Attempts to acquire this RwLock with exclusive write access until a
timeout is reached.
If the access could not be granted before the timeout expires, then
None is returned. Otherwise, an RAII guard is returned which will
release the exclusive access when it is dropped.
Sourcepub fn try_write_until(
&self,
timeout: <R as RawRwLockTimed>::Instant,
) -> Option<RwLockWriteGuard<'_, R, T>>
pub fn try_write_until( &self, timeout: <R as RawRwLockTimed>::Instant, ) -> Option<RwLockWriteGuard<'_, R, T>>
Attempts to acquire this RwLock with exclusive write access until a
timeout is reached.
If the access could not be granted before the timeout expires, then
None is returned. Otherwise, an RAII guard is returned which will
release the exclusive access when it is dropped.
Source§impl<R, T> RwLock<R, T>where
R: RawRwLockRecursive,
T: ?Sized,
impl<R, T> RwLock<R, T>where
R: RawRwLockRecursive,
T: ?Sized,
Sourcepub fn read_recursive(&self) -> RwLockReadGuard<'_, R, T>
pub fn read_recursive(&self) -> RwLockReadGuard<'_, R, T>
Locks this RwLock with shared read access, blocking the current thread
until it can be acquired.
The calling thread will be blocked until there are no more writers which hold the lock. There may be other readers currently inside the lock when this method returns.
Unlike read, this method is guaranteed to succeed without blocking if
another read lock is held at the time of the call. This allows a thread
to recursively lock a RwLock. However using this method can cause
writers to starve since readers no longer block if a writer is waiting
for the lock.
Returns an RAII guard which will release this thread’s shared access once it is dropped.
Sourcepub fn try_read_recursive(&self) -> Option<RwLockReadGuard<'_, R, T>>
pub fn try_read_recursive(&self) -> Option<RwLockReadGuard<'_, R, T>>
Attempts to acquire this RwLock with shared read access.
If the access could not be granted at this time, then None is returned.
Otherwise, an RAII guard is returned which will release the shared access
when it is dropped.
This method is guaranteed to succeed if another read lock is held at the
time of the call. See the documentation for read_recursive for details.
This function does not block.
Source§impl<R, T> RwLock<R, T>where
R: RawRwLockRecursiveTimed,
T: ?Sized,
impl<R, T> RwLock<R, T>where
R: RawRwLockRecursiveTimed,
T: ?Sized,
Sourcepub fn try_read_recursive_for(
&self,
timeout: <R as RawRwLockTimed>::Duration,
) -> Option<RwLockReadGuard<'_, R, T>>
pub fn try_read_recursive_for( &self, timeout: <R as RawRwLockTimed>::Duration, ) -> Option<RwLockReadGuard<'_, R, T>>
Attempts to acquire this RwLock with shared read access until a timeout
is reached.
If the access could not be granted before the timeout expires, then
None is returned. Otherwise, an RAII guard is returned which will
release the shared access when it is dropped.
This method is guaranteed to succeed without blocking if another read
lock is held at the time of the call. See the documentation for
read_recursive for details.
Sourcepub fn try_read_recursive_until(
&self,
timeout: <R as RawRwLockTimed>::Instant,
) -> Option<RwLockReadGuard<'_, R, T>>
pub fn try_read_recursive_until( &self, timeout: <R as RawRwLockTimed>::Instant, ) -> Option<RwLockReadGuard<'_, R, T>>
Attempts to acquire this RwLock with shared read access until a timeout
is reached.
If the access could not be granted before the timeout expires, then
None is returned. Otherwise, an RAII guard is returned which will
release the shared access when it is dropped.
Source§impl<R, T> RwLock<R, T>where
R: RawRwLockUpgrade,
T: ?Sized,
impl<R, T> RwLock<R, T>where
R: RawRwLockUpgrade,
T: ?Sized,
Sourcepub unsafe fn make_upgradable_guard_unchecked(
&self,
) -> RwLockUpgradableReadGuard<'_, R, T>
pub unsafe fn make_upgradable_guard_unchecked( &self, ) -> RwLockUpgradableReadGuard<'_, R, T>
Creates a new RwLockUpgradableReadGuard without checking if the lock is held.
§Safety
This method must only be called if the thread logically holds an upgradable read lock.
This function does not increment the read count of the lock. Calling this function when a
guard has already been produced is undefined behaviour unless the guard was forgotten
with mem::forget.
Sourcepub fn upgradable_read(&self) -> RwLockUpgradableReadGuard<'_, R, T>
pub fn upgradable_read(&self) -> RwLockUpgradableReadGuard<'_, R, T>
Locks this RwLock with upgradable read access, blocking the current thread
until it can be acquired.
The calling thread will be blocked until there are no more writers or other upgradable reads which hold the lock. There may be other readers currently inside the lock when this method returns.
Returns an RAII guard which will release this thread’s shared access once it is dropped.
Sourcepub fn try_upgradable_read(&self) -> Option<RwLockUpgradableReadGuard<'_, R, T>>
pub fn try_upgradable_read(&self) -> Option<RwLockUpgradableReadGuard<'_, R, T>>
Attempts to acquire this RwLock with upgradable read access.
If the access could not be granted at this time, then None is returned.
Otherwise, an RAII guard is returned which will release the shared access
when it is dropped.
This function does not block.
Source§impl<R, T> RwLock<R, T>where
R: RawRwLockUpgradeTimed,
T: ?Sized,
impl<R, T> RwLock<R, T>where
R: RawRwLockUpgradeTimed,
T: ?Sized,
Sourcepub fn try_upgradable_read_for(
&self,
timeout: <R as RawRwLockTimed>::Duration,
) -> Option<RwLockUpgradableReadGuard<'_, R, T>>
pub fn try_upgradable_read_for( &self, timeout: <R as RawRwLockTimed>::Duration, ) -> Option<RwLockUpgradableReadGuard<'_, R, T>>
Attempts to acquire this RwLock with upgradable read access until a timeout
is reached.
If the access could not be granted before the timeout expires, then
None is returned. Otherwise, an RAII guard is returned which will
release the shared access when it is dropped.
Sourcepub fn try_upgradable_read_until(
&self,
timeout: <R as RawRwLockTimed>::Instant,
) -> Option<RwLockUpgradableReadGuard<'_, R, T>>
pub fn try_upgradable_read_until( &self, timeout: <R as RawRwLockTimed>::Instant, ) -> Option<RwLockUpgradableReadGuard<'_, R, T>>
Attempts to acquire this RwLock with upgradable read access until a timeout
is reached.
If the access could not be granted before the timeout expires, then
None is returned. Otherwise, an RAII guard is returned which will
release the shared access when it is dropped.
Trait Implementations§
Source§impl<T> Reflect for RwLock<RawRwLock, T>where
T: Reflect,
impl<T> Reflect for RwLock<RawRwLock, T>where
T: Reflect,
fn source_path() -> &'static str
fn type_name(&self) -> &'static str
fn doc(&self) -> &'static str
Source§fn assembly_name(&self) -> &'static str
fn assembly_name(&self) -> &'static str
#[derive(Reflect)]) to ensure that this method will return correct assembly
name. In other words - there’s no guarantee, that any implementation other than proc-macro
will return a correct name of the assembly. Alternatively, you can use env!("CARGO_PKG_NAME")
as an implementation.Source§fn type_assembly_name() -> &'static str
fn type_assembly_name() -> &'static str
#[derive(Reflect)]) to ensure that this method will return correct assembly
name. In other words - there’s no guarantee, that any implementation other than proc-macro
will return a correct name of the assembly. Alternatively, you can use env!("CARGO_PKG_NAME")
as an implementation.fn fields_info(&self, func: &mut dyn FnMut(&[FieldInfo<'_, '_>]))
fn into_any(self: Box<RwLock<RawRwLock, T>>) -> Box<dyn Any>
fn as_any(&self, func: &mut dyn FnMut(&(dyn Any + 'static)))
fn as_any_mut(&mut self, func: &mut dyn FnMut(&mut (dyn Any + 'static)))
fn as_reflect(&self, func: &mut dyn FnMut(&(dyn Reflect + 'static)))
fn as_reflect_mut(&mut self, func: &mut dyn FnMut(&mut (dyn Reflect + 'static)))
fn set( &mut self, value: Box<dyn Reflect>, ) -> Result<Box<dyn Reflect>, Box<dyn Reflect>>
Source§fn set_field(
&mut self,
field: &str,
value: Box<dyn Reflect>,
func: &mut dyn FnMut(Result<Box<dyn Reflect>, Box<dyn Reflect>>),
)
fn set_field( &mut self, field: &str, value: Box<dyn Reflect>, func: &mut dyn FnMut(Result<Box<dyn Reflect>, Box<dyn Reflect>>), )
#[reflect(setter = ..)] or falls back to
Reflect::field_mutfn fields(&self, func: &mut dyn FnMut(&[&(dyn Reflect + 'static)]))
fn fields_mut( &mut self, func: &mut dyn FnMut(&mut [&mut (dyn Reflect + 'static)]), )
fn field( &self, name: &str, func: &mut dyn FnMut(Option<&(dyn Reflect + 'static)>), )
fn field_mut( &mut self, name: &str, func: &mut dyn FnMut(Option<&mut (dyn Reflect + 'static)>), )
fn as_array(&self, func: &mut dyn FnMut(Option<&(dyn ReflectArray + 'static)>))
fn as_array_mut( &mut self, func: &mut dyn FnMut(Option<&mut (dyn ReflectArray + 'static)>), )
fn as_list(&self, func: &mut dyn FnMut(Option<&(dyn ReflectList + 'static)>))
fn as_list_mut( &mut self, func: &mut dyn FnMut(Option<&mut (dyn ReflectList + 'static)>), )
fn as_inheritable_variable( &self, func: &mut dyn FnMut(Option<&(dyn ReflectInheritableVariable + 'static)>), )
fn as_inheritable_variable_mut( &mut self, func: &mut dyn FnMut(Option<&mut (dyn ReflectInheritableVariable + 'static)>), )
fn as_hash_map( &self, func: &mut dyn FnMut(Option<&(dyn ReflectHashMap + 'static)>), )
fn as_hash_map_mut( &mut self, func: &mut dyn FnMut(Option<&mut (dyn ReflectHashMap + 'static)>), )
impl<R, T> Send for RwLock<R, T>
impl<R, T> Sync for RwLock<R, T>
Auto Trait Implementations§
impl<R, T> !Freeze for RwLock<R, T>
impl<R, T> !RefUnwindSafe for RwLock<R, T>
impl<R, T> Unpin for RwLock<R, T>
impl<R, T> UnwindSafe for RwLock<R, T>
Blanket Implementations§
Source§impl<T> AsyncTaskResult for T
impl<T> AsyncTaskResult for T
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Any. Could be used to downcast a trait object
to a particular type.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Any. Could be used to downcast a trait object
to a particular type.fn into_any(self: Box<T>) -> Box<dyn Any>
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> FieldValue for Twhere
T: 'static,
impl<T> FieldValue for Twhere
T: 'static,
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> 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().Source§impl<T> ReflectBase for Twhere
T: Reflect,
impl<T> ReflectBase for Twhere
T: Reflect,
fn as_any_raw(&self) -> &(dyn Any + 'static)
fn as_any_raw_mut(&mut self) -> &mut (dyn Any + 'static)
Source§impl<T> ResolvePath for Twhere
T: Reflect,
impl<T> ResolvePath for Twhere
T: Reflect,
fn resolve_path<'p>( &self, path: &'p str, func: &mut dyn FnMut(Result<&(dyn Reflect + 'static), ReflectPathError<'p>>), )
fn resolve_path_mut<'p>( &mut self, path: &'p str, func: &mut dyn FnMut(Result<&mut (dyn Reflect + 'static), ReflectPathError<'p>>), )
fn get_resolve_path<'p, T>(
&self,
path: &'p str,
func: &mut dyn FnMut(Result<&T, ReflectPathError<'p>>),
)where
T: Reflect,
fn get_resolve_path_mut<'p, T>(
&mut self,
path: &'p str,
func: &mut dyn FnMut(Result<&mut T, ReflectPathError<'p>>),
)where
T: Reflect,
Source§impl<T> ScriptMessagePayload for T
impl<T> ScriptMessagePayload for T
Source§fn as_any_ref(&self) -> &(dyn Any + 'static)
fn as_any_ref(&self) -> &(dyn Any + 'static)
self as &dyn AnySource§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
self as &dyn AnySource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.