Skip to content

Commit

Permalink
Make the Ownership trait sealed
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Sep 9, 2021
1 parent 47e4749 commit e7ffccb
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions objc2_id/src/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,27 @@ use objc2::Message;
/// A type used to mark that a struct owns the object(s) it contains,
/// so it has the sole references to them.
pub enum Owned {}

/// A type used to mark that the object(s) a struct contains are shared,
/// so there may be other references to them.
pub enum Shared {}

mod private {
pub trait Sealed {}

impl Sealed for super::Owned {}
impl Sealed for super::Shared {}
}

/// A type that marks what type of ownership a struct has over the object(s)
/// it contains; specifically, either [`Owned`] or [`Shared`].
pub trait Ownership: Any {}
impl Ownership for Owned {}
impl Ownership for Shared {}
///
/// This trait is sealed and not meant to be implemented outside of the this
/// crate.
pub trait Ownership: private::Sealed {}

impl Ownership for super::Owned {}
impl Ownership for super::Shared {}

/// An pointer for Objective-C reference counted objects.
///
Expand Down

0 comments on commit e7ffccb

Please sign in to comment.