Skip to main content

miniextendr_api/
wrap_as.rs

1//! Explicit R class-system return markers.
2//!
3//! `WrapAsR6<T>` and its siblings select the constructor used by the generated
4//! R wrapper. The matching attribute is `#[miniextendr(wrap = "r6")]`.
5//! Both forms leave Rust-to-R value conversion to `T`; they only select the
6//! R-side wrapping expression. See `docs/MINIEXTENDR_ATTRIBUTE.md` for examples.
7//!
8//! `ConvertTo<T>` and `ConvertFrom<T>` additionally register an inherent S7
9//! method with `S7::convert`. `ConvertTo<T>` names the target payload;
10//! `ConvertFrom<Self>` infers the source from its static method's sole typed
11//! parameter. Both use the existing S7 class-name resolver, including registered
12//! R class renames, and have matching `s7(convert_to = "Target")` /
13//! `s7(convert_from = "Source")` attributes.
14//!
15//! Markers are recognized by their last path segment. Type aliases and renamed
16//! imports do not select wrapping. Put `Invisible`/`Visible` outside the whole
17//! return, and `Option`, `Result`, or `Vec` outside the class marker.
18//!
19//! The named target must have a compatible R class definition. Explicit wrapping
20//! does not consult the class registry or verify the selected system; a mismatch
21//! is reported by R when the generated constructor or method is used.
22
23use crate::IntoR;
24
25macro_rules! wrap_marker {
26    ($name:ident, $docs:literal) => {
27        #[doc = $docs]
28        #[repr(transparent)]
29        #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
30        pub struct $name<T>(pub T);
31
32        impl<T> $name<T> {
33            /// Wrap a value for an explicit R return class.
34            pub const fn new(value: T) -> Self {
35                Self(value)
36            }
37            /// Recover the Rust value.
38            pub fn into_inner(self) -> T {
39                self.0
40            }
41        }
42
43        impl<T> From<T> for $name<T> {
44            fn from(value: T) -> Self {
45                Self(value)
46            }
47        }
48
49        impl<T> std::ops::Deref for $name<T> {
50            type Target = T;
51            fn deref(&self) -> &T {
52                &self.0
53            }
54        }
55
56        impl<T> std::ops::DerefMut for $name<T> {
57            fn deref_mut(&mut self) -> &mut T {
58                &mut self.0
59            }
60        }
61
62        impl<T: IntoR> IntoR for $name<T> {
63            type Error = T::Error;
64            fn try_into_sexp(self) -> Result<crate::SEXP, Self::Error> {
65                self.0.try_into_sexp()
66            }
67            unsafe fn try_into_sexp_unchecked(self) -> Result<crate::SEXP, Self::Error> {
68                // SAFETY: the caller provides T's ordinary conversion guarantees.
69                unsafe { self.0.try_into_sexp_unchecked() }
70            }
71        }
72    };
73}
74
75#[doc = "Return `T` through its R6 constructor (`T$new(.ptr = value)`)."]
#[repr(transparent)]
pub struct WrapAsR6<T>(pub T);
#[automatically_derived]
impl<T: ::core::fmt::Debug> ::core::fmt::Debug for WrapAsR6<T> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_tuple_field1_finish(f, "WrapAsR6",
            &&self.0)
    }
}
#[automatically_derived]
impl<T: ::core::clone::Clone> ::core::clone::Clone for WrapAsR6<T> {
    #[inline]
    fn clone(&self) -> Self { WrapAsR6(::core::clone::Clone::clone(&self.0)) }
}
#[automatically_derived]
impl<T: ::core::marker::Copy> ::core::marker::Copy for WrapAsR6<T> { }
#[automatically_derived]
impl<T: ::core::cmp::PartialEq> ::core::marker::StructuralPartialEq for
    WrapAsR6<T> {
}
#[automatically_derived]
impl<T: ::core::cmp::PartialEq> ::core::cmp::PartialEq for WrapAsR6<T> {
    #[inline]
    fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
#[automatically_derived]
impl<T: ::core::cmp::Eq> ::core::cmp::Eq for WrapAsR6<T> {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) { let _: ::core::cmp::AssertParamIsEq<T>; }
}
#[automatically_derived]
impl<T: ::core::cmp::PartialOrd> ::core::cmp::PartialOrd for WrapAsR6<T> {
    #[inline]
    fn partial_cmp(&self, other: &Self)
        -> ::core::option::Option<::core::cmp::Ordering> {
        ::core::cmp::PartialOrd::partial_cmp(&self.0, &other.0)
    }
}
#[automatically_derived]
impl<T: ::core::cmp::Ord> ::core::cmp::Ord for WrapAsR6<T> {
    #[inline]
    fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
        ::core::cmp::Ord::cmp(&self.0, &other.0)
    }
}
#[automatically_derived]
impl<T: ::core::hash::Hash> ::core::hash::Hash for WrapAsR6<T> {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.0, state)
    }
}
#[automatically_derived]
impl<T: ::core::default::Default> ::core::default::Default for WrapAsR6<T> {
    #[inline]
    fn default() -> Self { WrapAsR6(::core::default::Default::default()) }
}
impl<T> WrapAsR6<T> {
    /// Wrap a value for an explicit R return class.
    pub const fn new(value: T) -> Self { Self(value) }
    /// Recover the Rust value.
    pub fn into_inner(self) -> T { self.0 }
}
impl<T> From<T> for WrapAsR6<T> {
    fn from(value: T) -> Self { Self(value) }
}
impl<T> std::ops::Deref for WrapAsR6<T> {
    type Target = T;
    fn deref(&self) -> &T { &self.0 }
}
impl<T> std::ops::DerefMut for WrapAsR6<T> {
    fn deref_mut(&mut self) -> &mut T { &mut self.0 }
}
impl<T: IntoR> IntoR for WrapAsR6<T> {
    type Error = T::Error;
    fn try_into_sexp(self) -> Result<crate::SEXP, Self::Error> {
        self.0.try_into_sexp()
    }
    unsafe fn try_into_sexp_unchecked(self)
        -> Result<crate::SEXP, Self::Error> {
        unsafe { self.0.try_into_sexp_unchecked() }
    }
}wrap_marker!(
76    WrapAsR6,
77    "Return `T` through its R6 constructor (`T$new(.ptr = value)`)."
78);
79#[doc = "Return `T` through its S7 constructor (`T(.ptr = value)`)."]
#[repr(transparent)]
pub struct WrapAsS7<T>(pub T);
#[automatically_derived]
impl<T: ::core::fmt::Debug> ::core::fmt::Debug for WrapAsS7<T> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_tuple_field1_finish(f, "WrapAsS7",
            &&self.0)
    }
}
#[automatically_derived]
impl<T: ::core::clone::Clone> ::core::clone::Clone for WrapAsS7<T> {
    #[inline]
    fn clone(&self) -> Self { WrapAsS7(::core::clone::Clone::clone(&self.0)) }
}
#[automatically_derived]
impl<T: ::core::marker::Copy> ::core::marker::Copy for WrapAsS7<T> { }
#[automatically_derived]
impl<T: ::core::cmp::PartialEq> ::core::marker::StructuralPartialEq for
    WrapAsS7<T> {
}
#[automatically_derived]
impl<T: ::core::cmp::PartialEq> ::core::cmp::PartialEq for WrapAsS7<T> {
    #[inline]
    fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
#[automatically_derived]
impl<T: ::core::cmp::Eq> ::core::cmp::Eq for WrapAsS7<T> {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) { let _: ::core::cmp::AssertParamIsEq<T>; }
}
#[automatically_derived]
impl<T: ::core::cmp::PartialOrd> ::core::cmp::PartialOrd for WrapAsS7<T> {
    #[inline]
    fn partial_cmp(&self, other: &Self)
        -> ::core::option::Option<::core::cmp::Ordering> {
        ::core::cmp::PartialOrd::partial_cmp(&self.0, &other.0)
    }
}
#[automatically_derived]
impl<T: ::core::cmp::Ord> ::core::cmp::Ord for WrapAsS7<T> {
    #[inline]
    fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
        ::core::cmp::Ord::cmp(&self.0, &other.0)
    }
}
#[automatically_derived]
impl<T: ::core::hash::Hash> ::core::hash::Hash for WrapAsS7<T> {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.0, state)
    }
}
#[automatically_derived]
impl<T: ::core::default::Default> ::core::default::Default for WrapAsS7<T> {
    #[inline]
    fn default() -> Self { WrapAsS7(::core::default::Default::default()) }
}
impl<T> WrapAsS7<T> {
    /// Wrap a value for an explicit R return class.
    pub const fn new(value: T) -> Self { Self(value) }
    /// Recover the Rust value.
    pub fn into_inner(self) -> T { self.0 }
}
impl<T> From<T> for WrapAsS7<T> {
    fn from(value: T) -> Self { Self(value) }
}
impl<T> std::ops::Deref for WrapAsS7<T> {
    type Target = T;
    fn deref(&self) -> &T { &self.0 }
}
impl<T> std::ops::DerefMut for WrapAsS7<T> {
    fn deref_mut(&mut self) -> &mut T { &mut self.0 }
}
impl<T: IntoR> IntoR for WrapAsS7<T> {
    type Error = T::Error;
    fn try_into_sexp(self) -> Result<crate::SEXP, Self::Error> {
        self.0.try_into_sexp()
    }
    unsafe fn try_into_sexp_unchecked(self)
        -> Result<crate::SEXP, Self::Error> {
        unsafe { self.0.try_into_sexp_unchecked() }
    }
}wrap_marker!(
80    WrapAsS7,
81    "Return `T` through its S7 constructor (`T(.ptr = value)`)."
82);
83#[doc = "Return `T` through `methods::new(\"T\", ptr = value)`."]
#[repr(transparent)]
pub struct WrapAsS4<T>(pub T);
#[automatically_derived]
impl<T: ::core::fmt::Debug> ::core::fmt::Debug for WrapAsS4<T> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_tuple_field1_finish(f, "WrapAsS4",
            &&self.0)
    }
}
#[automatically_derived]
impl<T: ::core::clone::Clone> ::core::clone::Clone for WrapAsS4<T> {
    #[inline]
    fn clone(&self) -> Self { WrapAsS4(::core::clone::Clone::clone(&self.0)) }
}
#[automatically_derived]
impl<T: ::core::marker::Copy> ::core::marker::Copy for WrapAsS4<T> { }
#[automatically_derived]
impl<T: ::core::cmp::PartialEq> ::core::marker::StructuralPartialEq for
    WrapAsS4<T> {
}
#[automatically_derived]
impl<T: ::core::cmp::PartialEq> ::core::cmp::PartialEq for WrapAsS4<T> {
    #[inline]
    fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
#[automatically_derived]
impl<T: ::core::cmp::Eq> ::core::cmp::Eq for WrapAsS4<T> {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) { let _: ::core::cmp::AssertParamIsEq<T>; }
}
#[automatically_derived]
impl<T: ::core::cmp::PartialOrd> ::core::cmp::PartialOrd for WrapAsS4<T> {
    #[inline]
    fn partial_cmp(&self, other: &Self)
        -> ::core::option::Option<::core::cmp::Ordering> {
        ::core::cmp::PartialOrd::partial_cmp(&self.0, &other.0)
    }
}
#[automatically_derived]
impl<T: ::core::cmp::Ord> ::core::cmp::Ord for WrapAsS4<T> {
    #[inline]
    fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
        ::core::cmp::Ord::cmp(&self.0, &other.0)
    }
}
#[automatically_derived]
impl<T: ::core::hash::Hash> ::core::hash::Hash for WrapAsS4<T> {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.0, state)
    }
}
#[automatically_derived]
impl<T: ::core::default::Default> ::core::default::Default for WrapAsS4<T> {
    #[inline]
    fn default() -> Self { WrapAsS4(::core::default::Default::default()) }
}
impl<T> WrapAsS4<T> {
    /// Wrap a value for an explicit R return class.
    pub const fn new(value: T) -> Self { Self(value) }
    /// Recover the Rust value.
    pub fn into_inner(self) -> T { self.0 }
}
impl<T> From<T> for WrapAsS4<T> {
    fn from(value: T) -> Self { Self(value) }
}
impl<T> std::ops::Deref for WrapAsS4<T> {
    type Target = T;
    fn deref(&self) -> &T { &self.0 }
}
impl<T> std::ops::DerefMut for WrapAsS4<T> {
    fn deref_mut(&mut self) -> &mut T { &mut self.0 }
}
impl<T: IntoR> IntoR for WrapAsS4<T> {
    type Error = T::Error;
    fn try_into_sexp(self) -> Result<crate::SEXP, Self::Error> {
        self.0.try_into_sexp()
    }
    unsafe fn try_into_sexp_unchecked(self)
        -> Result<crate::SEXP, Self::Error> {
        unsafe { self.0.try_into_sexp_unchecked() }
    }
}wrap_marker!(
84    WrapAsS4,
85    "Return `T` through `methods::new(\"T\", ptr = value)`."
86);
87#[doc = "Return `T` with its named S3 class."]
#[repr(transparent)]
pub struct WrapAsS3<T>(pub T);
#[automatically_derived]
impl<T: ::core::fmt::Debug> ::core::fmt::Debug for WrapAsS3<T> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_tuple_field1_finish(f, "WrapAsS3",
            &&self.0)
    }
}
#[automatically_derived]
impl<T: ::core::clone::Clone> ::core::clone::Clone for WrapAsS3<T> {
    #[inline]
    fn clone(&self) -> Self { WrapAsS3(::core::clone::Clone::clone(&self.0)) }
}
#[automatically_derived]
impl<T: ::core::marker::Copy> ::core::marker::Copy for WrapAsS3<T> { }
#[automatically_derived]
impl<T: ::core::cmp::PartialEq> ::core::marker::StructuralPartialEq for
    WrapAsS3<T> {
}
#[automatically_derived]
impl<T: ::core::cmp::PartialEq> ::core::cmp::PartialEq for WrapAsS3<T> {
    #[inline]
    fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
#[automatically_derived]
impl<T: ::core::cmp::Eq> ::core::cmp::Eq for WrapAsS3<T> {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) { let _: ::core::cmp::AssertParamIsEq<T>; }
}
#[automatically_derived]
impl<T: ::core::cmp::PartialOrd> ::core::cmp::PartialOrd for WrapAsS3<T> {
    #[inline]
    fn partial_cmp(&self, other: &Self)
        -> ::core::option::Option<::core::cmp::Ordering> {
        ::core::cmp::PartialOrd::partial_cmp(&self.0, &other.0)
    }
}
#[automatically_derived]
impl<T: ::core::cmp::Ord> ::core::cmp::Ord for WrapAsS3<T> {
    #[inline]
    fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
        ::core::cmp::Ord::cmp(&self.0, &other.0)
    }
}
#[automatically_derived]
impl<T: ::core::hash::Hash> ::core::hash::Hash for WrapAsS3<T> {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.0, state)
    }
}
#[automatically_derived]
impl<T: ::core::default::Default> ::core::default::Default for WrapAsS3<T> {
    #[inline]
    fn default() -> Self { WrapAsS3(::core::default::Default::default()) }
}
impl<T> WrapAsS3<T> {
    /// Wrap a value for an explicit R return class.
    pub const fn new(value: T) -> Self { Self(value) }
    /// Recover the Rust value.
    pub fn into_inner(self) -> T { self.0 }
}
impl<T> From<T> for WrapAsS3<T> {
    fn from(value: T) -> Self { Self(value) }
}
impl<T> std::ops::Deref for WrapAsS3<T> {
    type Target = T;
    fn deref(&self) -> &T { &self.0 }
}
impl<T> std::ops::DerefMut for WrapAsS3<T> {
    fn deref_mut(&mut self) -> &mut T { &mut self.0 }
}
impl<T: IntoR> IntoR for WrapAsS3<T> {
    type Error = T::Error;
    fn try_into_sexp(self) -> Result<crate::SEXP, Self::Error> {
        self.0.try_into_sexp()
    }
    unsafe fn try_into_sexp_unchecked(self)
        -> Result<crate::SEXP, Self::Error> {
        unsafe { self.0.try_into_sexp_unchecked() }
    }
}wrap_marker!(WrapAsS3, "Return `T` with its named S3 class.");
88#[doc = "Return `T` with its Env dispatch class."]
#[repr(transparent)]
pub struct WrapAsEnv<T>(pub T);
#[automatically_derived]
impl<T: ::core::fmt::Debug> ::core::fmt::Debug for WrapAsEnv<T> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_tuple_field1_finish(f, "WrapAsEnv",
            &&self.0)
    }
}
#[automatically_derived]
impl<T: ::core::clone::Clone> ::core::clone::Clone for WrapAsEnv<T> {
    #[inline]
    fn clone(&self) -> Self {
        WrapAsEnv(::core::clone::Clone::clone(&self.0))
    }
}
#[automatically_derived]
impl<T: ::core::marker::Copy> ::core::marker::Copy for WrapAsEnv<T> { }
#[automatically_derived]
impl<T: ::core::cmp::PartialEq> ::core::marker::StructuralPartialEq for
    WrapAsEnv<T> {
}
#[automatically_derived]
impl<T: ::core::cmp::PartialEq> ::core::cmp::PartialEq for WrapAsEnv<T> {
    #[inline]
    fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
#[automatically_derived]
impl<T: ::core::cmp::Eq> ::core::cmp::Eq for WrapAsEnv<T> {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) { let _: ::core::cmp::AssertParamIsEq<T>; }
}
#[automatically_derived]
impl<T: ::core::cmp::PartialOrd> ::core::cmp::PartialOrd for WrapAsEnv<T> {
    #[inline]
    fn partial_cmp(&self, other: &Self)
        -> ::core::option::Option<::core::cmp::Ordering> {
        ::core::cmp::PartialOrd::partial_cmp(&self.0, &other.0)
    }
}
#[automatically_derived]
impl<T: ::core::cmp::Ord> ::core::cmp::Ord for WrapAsEnv<T> {
    #[inline]
    fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
        ::core::cmp::Ord::cmp(&self.0, &other.0)
    }
}
#[automatically_derived]
impl<T: ::core::hash::Hash> ::core::hash::Hash for WrapAsEnv<T> {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.0, state)
    }
}
#[automatically_derived]
impl<T: ::core::default::Default> ::core::default::Default for WrapAsEnv<T> {
    #[inline]
    fn default() -> Self { WrapAsEnv(::core::default::Default::default()) }
}
impl<T> WrapAsEnv<T> {
    /// Wrap a value for an explicit R return class.
    pub const fn new(value: T) -> Self { Self(value) }
    /// Recover the Rust value.
    pub fn into_inner(self) -> T { self.0 }
}
impl<T> From<T> for WrapAsEnv<T> {
    fn from(value: T) -> Self { Self(value) }
}
impl<T> std::ops::Deref for WrapAsEnv<T> {
    type Target = T;
    fn deref(&self) -> &T { &self.0 }
}
impl<T> std::ops::DerefMut for WrapAsEnv<T> {
    fn deref_mut(&mut self) -> &mut T { &mut self.0 }
}
impl<T: IntoR> IntoR for WrapAsEnv<T> {
    type Error = T::Error;
    fn try_into_sexp(self) -> Result<crate::SEXP, Self::Error> {
        self.0.try_into_sexp()
    }
    unsafe fn try_into_sexp_unchecked(self)
        -> Result<crate::SEXP, Self::Error> {
        unsafe { self.0.try_into_sexp_unchecked() }
    }
}wrap_marker!(WrapAsEnv, "Return `T` with its Env dispatch class.");
89#[doc =
"Return `T` with its named vctrs class, preserving its existing class hierarchy."]
#[repr(transparent)]
pub struct WrapAsVctrs<T>(pub T);
#[automatically_derived]
impl<T: ::core::fmt::Debug> ::core::fmt::Debug for WrapAsVctrs<T> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_tuple_field1_finish(f, "WrapAsVctrs",
            &&self.0)
    }
}
#[automatically_derived]
impl<T: ::core::clone::Clone> ::core::clone::Clone for WrapAsVctrs<T> {
    #[inline]
    fn clone(&self) -> Self {
        WrapAsVctrs(::core::clone::Clone::clone(&self.0))
    }
}
#[automatically_derived]
impl<T: ::core::marker::Copy> ::core::marker::Copy for WrapAsVctrs<T> { }
#[automatically_derived]
impl<T: ::core::cmp::PartialEq> ::core::marker::StructuralPartialEq for
    WrapAsVctrs<T> {
}
#[automatically_derived]
impl<T: ::core::cmp::PartialEq> ::core::cmp::PartialEq for WrapAsVctrs<T> {
    #[inline]
    fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
#[automatically_derived]
impl<T: ::core::cmp::Eq> ::core::cmp::Eq for WrapAsVctrs<T> {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) { let _: ::core::cmp::AssertParamIsEq<T>; }
}
#[automatically_derived]
impl<T: ::core::cmp::PartialOrd> ::core::cmp::PartialOrd for WrapAsVctrs<T> {
    #[inline]
    fn partial_cmp(&self, other: &Self)
        -> ::core::option::Option<::core::cmp::Ordering> {
        ::core::cmp::PartialOrd::partial_cmp(&self.0, &other.0)
    }
}
#[automatically_derived]
impl<T: ::core::cmp::Ord> ::core::cmp::Ord for WrapAsVctrs<T> {
    #[inline]
    fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
        ::core::cmp::Ord::cmp(&self.0, &other.0)
    }
}
#[automatically_derived]
impl<T: ::core::hash::Hash> ::core::hash::Hash for WrapAsVctrs<T> {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.0, state)
    }
}
#[automatically_derived]
impl<T: ::core::default::Default> ::core::default::Default for WrapAsVctrs<T>
    {
    #[inline]
    fn default() -> Self { WrapAsVctrs(::core::default::Default::default()) }
}
impl<T> WrapAsVctrs<T> {
    /// Wrap a value for an explicit R return class.
    pub const fn new(value: T) -> Self { Self(value) }
    /// Recover the Rust value.
    pub fn into_inner(self) -> T { self.0 }
}
impl<T> From<T> for WrapAsVctrs<T> {
    fn from(value: T) -> Self { Self(value) }
}
impl<T> std::ops::Deref for WrapAsVctrs<T> {
    type Target = T;
    fn deref(&self) -> &T { &self.0 }
}
impl<T> std::ops::DerefMut for WrapAsVctrs<T> {
    fn deref_mut(&mut self) -> &mut T { &mut self.0 }
}
impl<T: IntoR> IntoR for WrapAsVctrs<T> {
    type Error = T::Error;
    fn try_into_sexp(self) -> Result<crate::SEXP, Self::Error> {
        self.0.try_into_sexp()
    }
    unsafe fn try_into_sexp_unchecked(self)
        -> Result<crate::SEXP, Self::Error> {
        unsafe { self.0.try_into_sexp_unchecked() }
    }
}wrap_marker!(
90    WrapAsVctrs,
91    "Return `T` with its named vctrs class, preserving its existing class hierarchy."
92);
93
94#[doc =
"Return an S7 target class and register the inherent method with `S7::convert`. The equivalent attribute is `s7(convert_to = \"Target\")`."]
#[repr(transparent)]
pub struct ConvertTo<T>(pub T);
#[automatically_derived]
impl<T: ::core::fmt::Debug> ::core::fmt::Debug for ConvertTo<T> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_tuple_field1_finish(f, "ConvertTo",
            &&self.0)
    }
}
#[automatically_derived]
impl<T: ::core::clone::Clone> ::core::clone::Clone for ConvertTo<T> {
    #[inline]
    fn clone(&self) -> Self {
        ConvertTo(::core::clone::Clone::clone(&self.0))
    }
}
#[automatically_derived]
impl<T: ::core::marker::Copy> ::core::marker::Copy for ConvertTo<T> { }
#[automatically_derived]
impl<T: ::core::cmp::PartialEq> ::core::marker::StructuralPartialEq for
    ConvertTo<T> {
}
#[automatically_derived]
impl<T: ::core::cmp::PartialEq> ::core::cmp::PartialEq for ConvertTo<T> {
    #[inline]
    fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
#[automatically_derived]
impl<T: ::core::cmp::Eq> ::core::cmp::Eq for ConvertTo<T> {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) { let _: ::core::cmp::AssertParamIsEq<T>; }
}
#[automatically_derived]
impl<T: ::core::cmp::PartialOrd> ::core::cmp::PartialOrd for ConvertTo<T> {
    #[inline]
    fn partial_cmp(&self, other: &Self)
        -> ::core::option::Option<::core::cmp::Ordering> {
        ::core::cmp::PartialOrd::partial_cmp(&self.0, &other.0)
    }
}
#[automatically_derived]
impl<T: ::core::cmp::Ord> ::core::cmp::Ord for ConvertTo<T> {
    #[inline]
    fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
        ::core::cmp::Ord::cmp(&self.0, &other.0)
    }
}
#[automatically_derived]
impl<T: ::core::hash::Hash> ::core::hash::Hash for ConvertTo<T> {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.0, state)
    }
}
#[automatically_derived]
impl<T: ::core::default::Default> ::core::default::Default for ConvertTo<T> {
    #[inline]
    fn default() -> Self { ConvertTo(::core::default::Default::default()) }
}
impl<T> ConvertTo<T> {
    /// Wrap a value for an explicit R return class.
    pub const fn new(value: T) -> Self { Self(value) }
    /// Recover the Rust value.
    pub fn into_inner(self) -> T { self.0 }
}
impl<T> From<T> for ConvertTo<T> {
    fn from(value: T) -> Self { Self(value) }
}
impl<T> std::ops::Deref for ConvertTo<T> {
    type Target = T;
    fn deref(&self) -> &T { &self.0 }
}
impl<T> std::ops::DerefMut for ConvertTo<T> {
    fn deref_mut(&mut self) -> &mut T { &mut self.0 }
}
impl<T: IntoR> IntoR for ConvertTo<T> {
    type Error = T::Error;
    fn try_into_sexp(self) -> Result<crate::SEXP, Self::Error> {
        self.0.try_into_sexp()
    }
    unsafe fn try_into_sexp_unchecked(self)
        -> Result<crate::SEXP, Self::Error> {
        unsafe { self.0.try_into_sexp_unchecked() }
    }
}wrap_marker!(
95    ConvertTo,
96    "Return an S7 target class and register the inherent method with `S7::convert`. The equivalent attribute is `s7(convert_to = \"Target\")`."
97);
98#[doc =
"Return the enclosing S7 class from a static conversion method. Its sole typed source parameter determines the `s7(convert_from = \"Source\")` registration."]
#[repr(transparent)]
pub struct ConvertFrom<T>(pub T);
#[automatically_derived]
impl<T: ::core::fmt::Debug> ::core::fmt::Debug for ConvertFrom<T> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_tuple_field1_finish(f, "ConvertFrom",
            &&self.0)
    }
}
#[automatically_derived]
impl<T: ::core::clone::Clone> ::core::clone::Clone for ConvertFrom<T> {
    #[inline]
    fn clone(&self) -> Self {
        ConvertFrom(::core::clone::Clone::clone(&self.0))
    }
}
#[automatically_derived]
impl<T: ::core::marker::Copy> ::core::marker::Copy for ConvertFrom<T> { }
#[automatically_derived]
impl<T: ::core::cmp::PartialEq> ::core::marker::StructuralPartialEq for
    ConvertFrom<T> {
}
#[automatically_derived]
impl<T: ::core::cmp::PartialEq> ::core::cmp::PartialEq for ConvertFrom<T> {
    #[inline]
    fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
#[automatically_derived]
impl<T: ::core::cmp::Eq> ::core::cmp::Eq for ConvertFrom<T> {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) { let _: ::core::cmp::AssertParamIsEq<T>; }
}
#[automatically_derived]
impl<T: ::core::cmp::PartialOrd> ::core::cmp::PartialOrd for ConvertFrom<T> {
    #[inline]
    fn partial_cmp(&self, other: &Self)
        -> ::core::option::Option<::core::cmp::Ordering> {
        ::core::cmp::PartialOrd::partial_cmp(&self.0, &other.0)
    }
}
#[automatically_derived]
impl<T: ::core::cmp::Ord> ::core::cmp::Ord for ConvertFrom<T> {
    #[inline]
    fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
        ::core::cmp::Ord::cmp(&self.0, &other.0)
    }
}
#[automatically_derived]
impl<T: ::core::hash::Hash> ::core::hash::Hash for ConvertFrom<T> {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.0, state)
    }
}
#[automatically_derived]
impl<T: ::core::default::Default> ::core::default::Default for ConvertFrom<T>
    {
    #[inline]
    fn default() -> Self { ConvertFrom(::core::default::Default::default()) }
}
impl<T> ConvertFrom<T> {
    /// Wrap a value for an explicit R return class.
    pub const fn new(value: T) -> Self { Self(value) }
    /// Recover the Rust value.
    pub fn into_inner(self) -> T { self.0 }
}
impl<T> From<T> for ConvertFrom<T> {
    fn from(value: T) -> Self { Self(value) }
}
impl<T> std::ops::Deref for ConvertFrom<T> {
    type Target = T;
    fn deref(&self) -> &T { &self.0 }
}
impl<T> std::ops::DerefMut for ConvertFrom<T> {
    fn deref_mut(&mut self) -> &mut T { &mut self.0 }
}
impl<T: IntoR> IntoR for ConvertFrom<T> {
    type Error = T::Error;
    fn try_into_sexp(self) -> Result<crate::SEXP, Self::Error> {
        self.0.try_into_sexp()
    }
    unsafe fn try_into_sexp_unchecked(self)
        -> Result<crate::SEXP, Self::Error> {
        unsafe { self.0.try_into_sexp_unchecked() }
    }
}wrap_marker!(
99    ConvertFrom,
100    "Return the enclosing S7 class from a static conversion method. Its sole typed source parameter determines the `s7(convert_from = \"Source\")` registration."
101);