58 lines
1.3 KiB
Text
58 lines
1.3 KiB
Text
|
#![no_implicit_prelude]
|
||
|
|
||
|
{%- for ty in typedefs %}
|
||
|
|
||
|
pub(crate) struct {{ty.ident}}{{ty.generics|if_some}}({{ty.inner_ty}});
|
||
|
|
||
|
#[allow(dead_code)]
|
||
|
impl{{ty.generics|if_some}} {{ty.ident}}{{ty.generics|if_some}} {
|
||
|
pub(crate) fn new(arg: {{ty.inner_ty}}) -> Self {
|
||
|
Self(arg)
|
||
|
}
|
||
|
|
||
|
pub(crate) fn into_inner(this: Self) -> {{ty.inner_ty}} {
|
||
|
this.0
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl{{ty.generics|if_some}} ::core::clone::Clone for {{ty.ident}}{{ty.generics|if_some}}
|
||
|
where
|
||
|
{{ty.inner_ty}}: ::core::clone::Clone
|
||
|
{
|
||
|
fn clone(&self) -> Self {
|
||
|
Self::new(self.0.clone())
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl{{ty.generics|if_some}} ::core::ops::Deref for {{ty.ident}}{{ty.generics|if_some}} {
|
||
|
type Target = {{ty.inner_ty}};
|
||
|
|
||
|
fn deref(&self) -> &Self::Target {
|
||
|
&self.0
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl{{ty.generics|if_some}} ::core::ops::DerefMut for {{ty.ident}}{{ty.generics|if_some}} {
|
||
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
||
|
&mut self.0
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl{{ty.generics|if_some}} ::core::fmt::Debug for {{ty.ident}}{{ty.generics|if_some}}
|
||
|
{%- match ty.generics %}
|
||
|
{%- when Some with (generics) %}
|
||
|
where
|
||
|
{%- for param in generics.params %}
|
||
|
{{param}}: ::core::fmt::Debug,
|
||
|
{%- endfor %}
|
||
|
{%- when _ %}
|
||
|
{%- endmatch %}
|
||
|
{
|
||
|
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
|
||
|
f.debug_tuple(::core::stringify!({{ty.ident}}))
|
||
|
.field(&self.0)
|
||
|
.finish()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
{%- endfor %}
|