#![cfg_attr(feature = "apple", doc = "```")]
#![cfg_attr(not(feature = "apple"), doc = "```no_run")]
mod allocated;
mod autorelease;
mod id;
mod id_forwarding_impls;
mod id_traits;
mod ownership;
mod weak_id;
#[cfg(test)]
mod test_object;
pub use self::allocated::Allocated;
pub use self::autorelease::{autoreleasepool, AutoreleasePool, AutoreleaseSafe};
pub use self::id::Id;
pub use self::id_traits::{DefaultId, SliceId, SliceIdMut};
pub use self::ownership::{Owned, Ownership, Shared};
pub use self::weak_id::WeakId;
#[cfg(test)]
pub(crate) use self::test_object::{RcTestObject, ThreadTestData};
#[cfg(test)]
mod tests {
use core::marker::PhantomData;
use core::mem::size_of;
use super::{Id, Owned, Ownership, Shared, WeakId};
use crate::runtime::Object;
#[repr(C)]
struct TestType {
inner: Object,
}
#[repr(C)]
struct MyObject<'a> {
inner: Object,
p: PhantomData<&'a str>,
}
#[allow(unused)]
fn assert_id_variance<'a, 'b, O: Ownership>(
obj: &'a Id<MyObject<'static>, O>,
) -> &'a Id<MyObject<'b>, O> {
obj
}
#[allow(unused)]
fn assert_weak_id_variance<'a, 'b>(
obj: &'a WeakId<MyObject<'static>>,
) -> &'a WeakId<MyObject<'b>> {
obj
}
#[test]
fn test_size_of() {
assert_eq!(size_of::<Id<TestType, Owned>>(), size_of::<&TestType>());
assert_eq!(size_of::<Id<TestType, Shared>>(), size_of::<&TestType>());
assert_eq!(
size_of::<Option<Id<TestType, Owned>>>(),
size_of::<&TestType>()
);
assert_eq!(
size_of::<Option<Id<TestType, Shared>>>(),
size_of::<&TestType>()
);
assert_eq!(
size_of::<Option<WeakId<TestType>>>(),
size_of::<*const ()>()
);
}
}