Skip to content

Commit e41d1c1

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

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

objc2_id/src/id.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use alloc::borrow;
22
use alloc::boxed::Box;
3-
use core::any::Any;
43
use core::cell::UnsafeCell;
54
use core::fmt;
65
use core::hash;
@@ -17,13 +16,25 @@ use objc2::Message;
1716
/// A type used to mark that a struct owns the object(s) it contains,
1817
/// so it has the sole references to them.
1918
pub enum Owned {}
19+
2020
/// A type used to mark that the object(s) a struct contains are shared,
2121
/// so there may be other references to them.
2222
pub enum Shared {}
2323

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

0 commit comments

Comments
 (0)