pub struct UseRwLockMutation {
pub target_struct: Option<String>,
}Expand description
Suggests replacing Mutex with RwLock for read-heavy access patterns.
Detection: Mutex fields with collections (HashMap, Vec, etc.) that are typically read more often than written.
§Example
ⓘ
// Before
struct Cache {
data: Mutex<HashMap<String, Value>>,
}
// After (suggested)
struct Cache {
data: RwLock<HashMap<String, Value>>,
}Fields§
§target_struct: Option<String>Only apply to specific struct
Implementations§
Trait Implementations§
Source§impl Clone for UseRwLockMutation
impl Clone for UseRwLockMutation
Source§fn clone(&self) -> UseRwLockMutation
fn clone(&self) -> UseRwLockMutation
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for UseRwLockMutation
impl Debug for UseRwLockMutation
Source§impl Default for UseRwLockMutation
impl Default for UseRwLockMutation
Source§fn default() -> UseRwLockMutation
fn default() -> UseRwLockMutation
Returns the “default value” for a type. Read more
Source§impl Detect for UseRwLockMutation
impl Detect for UseRwLockMutation
Source§fn category(&self) -> DetectCategory
fn category(&self) -> DetectCategory
Get the category for detected opportunities
Source§fn detect_name(&self) -> &'static str
fn detect_name(&self) -> &'static str
Get the mutation/pattern name
Source§fn detect_description(&self) -> &str
fn detect_description(&self) -> &str
Get description
Source§impl Mutation for UseRwLockMutation
impl Mutation for UseRwLockMutation
Source§fn mutation_type(&self) -> &'static str
fn mutation_type(&self) -> &'static str
Get the mutation type name
Source§fn validate(&self, _file: &PureFile) -> ValidationResult
fn validate(&self, _file: &PureFile) -> ValidationResult
Validate the mutation before applying Read more
Source§fn can_proceed(&self, file: &PureFile, strategy: ValidationStrategy) -> bool
fn can_proceed(&self, file: &PureFile, strategy: ValidationStrategy) -> bool
Check if this mutation can proceed with the given strategy
Auto Trait Implementations§
impl Freeze for UseRwLockMutation
impl RefUnwindSafe for UseRwLockMutation
impl Send for UseRwLockMutation
impl Sync for UseRwLockMutation
impl Unpin for UseRwLockMutation
impl UnsafeUnpin for UseRwLockMutation
impl UnwindSafe for UseRwLockMutation
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
Mutably borrows from an owned value. Read more