use core::fmt::Debug;
use core::hash::Hash;
use core::panic::{RefUnwindSafe, UnwindSafe};
use super::AutoreleaseSafe;
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
enum Never {}
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
pub struct Owned {
inner: Never,
}
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
pub struct Shared {
inner: Never,
}
mod private {
pub trait Sealed {}
impl Sealed for super::Owned {}
impl Sealed for super::Shared {}
}
pub trait Ownership:
private::Sealed
+ 'static
+ Sized
+ Send
+ Sync
+ Unpin
+ UnwindSafe
+ RefUnwindSafe
+ Clone
+ Copy
+ PartialEq
+ Eq
+ PartialOrd
+ Ord
+ Hash
+ Debug
+ AutoreleaseSafe
{
}
impl Ownership for Owned {}
impl Ownership for Shared {}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_generic_ownership_traits() {
fn assert_partialeq<T: PartialEq>() {}
assert_partialeq::<Shared>();
assert_partialeq::<Owned>();
fn test_ownership_implies_partialeq<O: Ownership>() {
assert_partialeq::<O>();
}
test_ownership_implies_partialeq::<Shared>();
test_ownership_implies_partialeq::<Owned>();
}
}