turbocow 0.3.0-beta.2

Compact, clone-on-write vectors, strings, maps and sets with inline + referenced storage — a superset of ecow.
Documentation
// When nightly feature is available, re-export from core
#[cfg(feature = "nightly-phantom-variance")]
pub use core::marker::PhantomCovariantLifetime;

// Polyfill for stable
#[cfg(not(feature = "nightly-phantom-variance"))]
mod polyfill {
    use core::marker::PhantomData;

    /// Zero-sized type used to mark a lifetime as covariant.
    ///
    /// This is a polyfill for [`core::marker::PhantomCovariantLifetime`]
    /// (nightly `phantom_variance_markers`, tracking issue #135806).
    ///
    /// Covariant lifetimes must live at least as long as declared.
    /// See [the reference][1] for more information.
    ///
    /// [1]: https://doc.rust-lang.org/stable/reference/subtyping.html#variance
    ///
    /// ## Layout
    ///
    /// For all `'a`, the following are guaranteed:
    /// * `size_of::<PhantomCovariantLifetime<'a>>() == 0`
    /// * `align_of::<PhantomCovariantLifetime<'a>>() == 1`
    #[derive(Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
    #[repr(transparent)]
    pub struct PhantomCovariantLifetime<'a>(PhantomData<fn() -> &'a ()>);

    impl PhantomCovariantLifetime<'_> {
        /// Constructs a new instance of the variance marker.
        pub const fn new() -> Self {
            Self(PhantomData)
        }
    }

    impl core::fmt::Debug for PhantomCovariantLifetime<'_> {
        fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
            f.write_str("PhantomCovariantLifetime")
        }
    }
}

#[cfg(not(feature = "nightly-phantom-variance"))]
pub use polyfill::PhantomCovariantLifetime;