Skip to content

Commit e7ffccb

Browse files
committed
Make the Ownership trait sealed
1 parent 47e4749 commit e7ffccb

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

objc2_id/src/id.rs

+15-3
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,27 @@ use objc2::Message;
1717
/// A type used to mark that a struct owns the object(s) it contains,
1818
/// so it has the sole references to them.
1919
pub enum Owned {}
20+
2021
/// A type used to mark that the object(s) a struct contains are shared,
2122
/// so there may be other references to them.
2223
pub enum Shared {}
2324

25+
mod private {
26+
pub trait Sealed {}
27+
28+
impl Sealed for super::Owned {}
29+
impl Sealed for super::Shared {}
30+
}
31+
2432
/// A type that marks what type of ownership a struct has over the object(s)
2533
/// it contains; specifically, either [`Owned`] or [`Shared`].
26-
pub trait Ownership: Any {}
27-
impl Ownership for Owned {}
28-
impl Ownership for Shared {}
34+
///
35+
/// This trait is sealed and not meant to be implemented outside of the this
36+
/// crate.
37+
pub trait Ownership: private::Sealed {}
38+
39+
impl Ownership for super::Owned {}
40+
impl Ownership for super::Shared {}
2941

3042
/// An pointer for Objective-C reference counted objects.
3143
///

0 commit comments

Comments
 (0)