Skip to content

Commit ad11ebf

Browse files
committed
Make the implementation details of IsMainThreadOnly more hidden
In case we'd want to add more main thread class kinds in the future
1 parent dca2005 commit ad11ebf

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

crates/objc2/src/mutability.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,9 @@ mod private {
250250
impl MutabilityIsMutable for Mutable {}
251251
impl<IS: ?Sized> MutabilityIsMutable for MutableWithImmutableSuperclass<IS> {}
252252

253+
pub trait MutabilityIsMainThreadOnly: Mutability {}
254+
impl MutabilityIsMainThreadOnly for MainThreadOnly {}
255+
253256
// TODO: Trait for objects whose `hash` is guaranteed to never change,
254257
// which allows it to be used as a key in `NSDictionary`.
255258
}
@@ -341,7 +344,10 @@ impl<T: ?Sized + ClassType> IsMutable for T where T::Mutability: private::Mutabi
341344
//
342345
// Note: MainThreadMarker::from relies on this.
343346
pub trait IsMainThreadOnly: ClassType {}
344-
impl<T: ?Sized + ClassType<Mutability = MainThreadOnly>> IsMainThreadOnly for T {}
347+
impl<T: ?Sized + ClassType> IsMainThreadOnly for T where
348+
T::Mutability: private::MutabilityIsMainThreadOnly
349+
{
350+
}
345351

346352
#[cfg(test)]
347353
mod tests {

0 commit comments

Comments
 (0)