-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor Ownership and WeakId into their own files
- Loading branch information
Showing
4 changed files
with
209 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/// 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`]. | ||
/// | ||
/// This trait is sealed and not meant to be implemented outside of the this | ||
/// crate. | ||
pub trait Ownership: private::Sealed + 'static {} | ||
|
||
impl Ownership for Owned {} | ||
impl Ownership for Shared {} |
Oops, something went wrong.